Problem: Stewie the Rabbit explores a new parallel universe. This two dimensional universe has the shape of a rectangular grid, containing n lines and m columns. The universe is very small: one cell of the grid can only contain one particle. Each particle in this universe is either static or dynamic. Each static particle always remains in one and the same position. Due to unintelligible gravitation laws no two static particles in the parallel universe can be present in one column or row, and they also can't be present in the diagonally adjacent cells. A dynamic particle appears in a random empty cell, randomly chooses the destination cell (destination cell may coincide with the start cell, see the samples) and moves there along the shortest path through the cells, unoccupied by the static particles. All empty cells have the same probability of being selected as the beginning or end of the path. Having reached the destination cell, the particle disappears. Only one dynamic particle can exist at one moment of time. This particle can move from a cell to a cell if they have an adjacent side, and this transition takes exactly one galactic second. Stewie got interested in what is the average lifespan of one particle in the given universe.

Input

The first line contains two space-separated integers: n, m (2 ≤ n, m ≤ 1000) which represent the sizes of the universe. The next n lines containing m symbols each describe the universe without dynamic particles — the j-th symbol of the i-th line equals to 'X' if the cell is occupied by a static particle, and to '.' if it is empty. It is guaranteed that the described universe satisfies the properties described above, that is no two static particles can be in one column or in one row, besides, they can't be positioned in the diagonally adjacent cells.

Output

You have to print on a single line a single number which is the average life span of a particle with an accuracy of at least 6 decimal places.

The answer will be accepted if it is within 10 - 6 of absolute or relative error from the correct answer.

Examples

Input

2 2
..
.X


Output

0.888888888889


Input

3 3
...
.X.
...


Output

2.000000000000

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * Created by hama_du on 15/09/07.
 */
public class D {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int m = in.nextInt();

        char[][] map = new char[n][];
        for (int i = 0; i < n ; i++) {
            map[i] = in.nextToken().toCharArray();
        }

        int all = 0;
        int[] degX = new int[m];
        int[] degY = new int[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m ; j++) {
                if (map[i][j] == '.') {
                    degX[j]++;
                    degY[i]++;
                    all++;
                }
            }
        }
        double base = solve(degX) + solve(degY);

        int[][] x = new int[1000][2];
        int xn = 0;
        for (int i = 0; i < n ; i++) {
            for (int j = 0; j < m ; j++) {
               if (map[i][j] == 'X') {
                   x[xn][0] = i;
                   x[xn][1] = j;
                   xn++;
               }
            }
        }
        x = Arrays.copyOf(x, xn);

        long additionalMove = 0;

        // vertical move : sort by x
        for (final int xy : new int[]{0, 1}) {
            Arrays.sort(x, (x1, x2) -> x1[1-xy]-x2[1-xy]);
            for (int i = 0; i < xn; i++) {
                // bottom to top
                {
                    int to = i;
                    for (int j = i+1; j < xn; j++) {
                        if (x[j][1-xy] != x[j-1][1-xy]+1 || x[j-1][xy] >= x[j][xy]) {
                            break;
                        }
                        to++;
                    }
                    // fr-to
                    int max = (xy == 0) ? n : m;
                    for (int j = i; j <= to; j++) {
                        additionalMove += ((j == i) ? 2 : 4) * x[i][xy] * (max-x[j][xy]-1);
                    }
                }
                // top to bottom
                {
                    int to = i;
                    for (int j = i+1; j < xn; j++) {
                        if (x[j][1-xy] != x[j-1][1-xy]+1 || x[j-1][xy] <= x[j][xy]) {
                            break;
                        }
                        to++;
                    }
                    // fr-to
                    int max = (xy == 0) ? n : m;
                    for (int j = i; j <= to; j++) {
                        additionalMove += ((j == i) ? 2 : 4) * (max-x[i][xy]-1) * x[j][xy];
                    }
                }
            }
        }

        out.println(base + additionalMove * 1.0d / all / all);
        out.flush();
    }

    private static double solve(int[] deg) {
        int n = deg.length;
        int total = 0;
        for (int i = 0; i < n ; i++) {
            total += deg[i];
        }
        double ret = 0;
        for (int i = 0; i < n ; i++) {
            for (int j = 0; j < n ; j++) {
                ret += Math.abs(i-j) * deg[i] * deg[j];
            }
        }
        return ret / total / total;
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}