import java.util.*;

public class Euler280 {
    static final int SIZE = 5;
    static final int CELLS = SIZE * SIZE;
    static final int COLS = 5;
    static final int MASK_COUNT = 1 << COLS;
    static final int FULL_MASK = MASK_COUNT - 1;
    static final int RHS_COUNT = 1 + COLS;

    static class Grid {
        int[][] neighbors = new int[CELLS][4];
        int[] degree = new int[CELLS];

        Grid() {
            for (int y = 0; y < SIZE; ++y) {
                for (int x = 0; x < SIZE; ++x) {
                    int p = y * SIZE + x;
                    int d = 0;
                    if (x > 0)
                        neighbors[p][d++] = p - 1;
                    if (x + 1 < SIZE)
                        neighbors[p][d++] = p + 1;
                    if (y > 0)
                        neighbors[p][d++] = p - SIZE;
                    if (y + 1 < SIZE)
                        neighbors[p][d++] = p + SIZE;
                    degree[p] = d;
                }
            }
        }
    }

    static boolean solveLinearSystem(double[][] a, double[][] rhs) {
        double eps = 1e-15;

        for (int col = 0; col < CELLS; ++col) {
            int pivot = col;
            double best = Math.abs(a[col][col]);
            for (int row = col + 1; row < CELLS; ++row) {
                double cand = Math.abs(a[row][col]);
                if (cand > best) {
                    best = cand;
                    pivot = row;
                }
            }

            if (best < eps)
                return false;

            if (pivot != col) {
                double[] tmpA = a[pivot];
                a[pivot] = a[col];
                a[col] = tmpA;
                double[] tmpR = rhs[pivot];
                rhs[pivot] = rhs[col];
                rhs[col] = tmpR;
            }

            double invPivot = 1.0 / a[col][col];
            for (int j = col; j < CELLS; ++j)
                a[col][j] *= invPivot;
            for (int r = 0; r < RHS_COUNT; ++r)
                rhs[col][r] *= invPivot;

            for (int row = 0; row < CELLS; ++row) {
                if (row == col)
                    continue;
                double factor = a[row][col];
                if (Math.abs(factor) < eps)
                    continue;
                for (int j = col; j < CELLS; ++j)
                    a[row][j] -= factor * a[col][j];
                for (int r = 0; r < RHS_COUNT; ++r)
                    rhs[row][r] -= factor * rhs[col][r];
            }
        }
        return true;
    }

    static class HittingData {
        double[] expect = new double[CELLS];
        double[][] prob = new double[CELLS][COLS];
    }

    static HittingData solveHittingData(Grid grid, int row, int mask) {
        HittingData data = new HittingData();
        boolean[] isTarget = new boolean[CELLS];

        for (int col = 0; col < COLS; ++col) {
            if ((mask & (1 << col)) != 0) {
                isTarget[row * SIZE + col] = true;
            }
        }

        double[][] a = new double[CELLS][CELLS];
        double[][] rhs = new double[CELLS][RHS_COUNT];

        for (int state = 0; state < CELLS; ++state) {
            if (isTarget[state]) {
                a[state][state] = 1.0;
                rhs[state][0] = 0.0;
                int col = state % SIZE;
                rhs[state][1 + col] = 1.0;
                continue;
            }

            a[state][state] = 1.0;
            int deg = grid.degree[state];
            double step = 1.0 / deg;
            for (int i = 0; i < deg; ++i) {
                int nb = grid.neighbors[state][i];
                a[state][nb] -= step;
            }
            rhs[state][0] = 1.0;
        }

        if (!solveLinearSystem(a, rhs))
            return null;

        for (int state = 0; state < CELLS; ++state) {
            data.expect[state] = rhs[state][0];
            for (int col = 0; col < COLS; ++col) {
                data.prob[state][col] = rhs[state][1 + col];
            }
        }

        return data;
    }

    static class SolutionData {
        HittingData[] hitTop = new HittingData[MASK_COUNT];
        HittingData[] hitBottom = new HittingData[MASK_COUNT];
        double[][][] expectedNc = new double[MASK_COUNT][MASK_COUNT][CELLS];
        double[][][] expectedC = new double[MASK_COUNT][MASK_COUNT][CELLS];
    }

    static boolean buildSolutionData(SolutionData out) {
        Grid grid = new Grid();

        for (int mask = 1; mask < MASK_COUNT; ++mask) {
            out.hitTop[mask] = solveHittingData(grid, 0, mask);
            if (out.hitTop[mask] == null)
                return false;
            out.hitBottom[mask] = solveHittingData(grid, SIZE - 1, mask);
            if (out.hitBottom[mask] == null)
                return false;
        }

        int[] popcount = new int[MASK_COUNT];
        for (int mask = 0; mask < MASK_COUNT; ++mask) {
            popcount[mask] = Integer.bitCount(mask);
        }

        for (int pos = 0; pos < CELLS; ++pos) {
            out.expectedNc[0][FULL_MASK][pos] = 0.0;
        }

        for (int topCount = 4; topCount >= 0; --topCount) {
            for (int topMask = 0; topMask < MASK_COUNT; ++topMask) {
                if (popcount[topMask] != topCount)
                    continue;
                int emptyTopMask = FULL_MASK ^ topMask;
                HittingData drop = out.hitTop[emptyTopMask];

                for (int bottomMask = 0; bottomMask < MASK_COUNT; ++bottomMask) {
                    if (popcount[bottomMask] != 4 - topCount)
                        continue;

                    for (int pos = 0; pos < CELLS; ++pos) {
                        double value = drop.expect[pos];
                        for (int col = 0; col < COLS; ++col) {
                            int bit = 1 << col;
                            if ((emptyTopMask & bit) == 0)
                                continue;
                            value += drop.prob[pos][col] * out.expectedNc[bottomMask][topMask | bit][col];
                        }
                        out.expectedC[bottomMask][topMask][pos] = value;
                    }
                }
            }

            for (int topMask = 0; topMask < MASK_COUNT; ++topMask) {
                if (popcount[topMask] != topCount)
                    continue;
                for (int bottomMask = 0; bottomMask < MASK_COUNT; ++bottomMask) {
                    if (popcount[bottomMask] != 5 - topCount)
                        continue;

                    HittingData pick = out.hitBottom[bottomMask];
                    for (int pos = 0; pos < CELLS; ++pos) {
                        double value = pick.expect[pos];
                        for (int col = 0; col < COLS; ++col) {
                            int bit = 1 << col;
                            if ((bottomMask & bit) == 0)
                                continue;
                            value += pick.prob[pos][col]
                                    * out.expectedC[bottomMask ^ bit][topMask][(SIZE - 1) * SIZE + col];
                        }
                        out.expectedNc[bottomMask][topMask][pos] = value;
                    }
                }
            }
        }
        return true;
    }

    public static String solve() {
        SolutionData data = new SolutionData();
        if (!buildSolutionData(data))
            return "Error";

        int initialPos = 2 * SIZE + 2;
        int initialBottomMask = FULL_MASK;
        int initialTopMask = 0;
        double ans = data.expectedNc[initialBottomMask][initialTopMask][initialPos];

        return String.format(Locale.US, "%.6f", ans);
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
