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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Locale;

public class D53 {

    static StreamTokenizer in;
    static PrintWriter out;
    
    static int nextInt() throws IOException {
        in.nextToken();
        return (int)in.nval;
    }
    
    static String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);

        in.ordinaryChar('.');
        in.wordChars('.', '.');
        
        int n = nextInt(), m = nextInt();
        int k = 0;
        boolean[][] map = new boolean[n][m];
        for (int i = 0; i < n; i++) {
            char[] s = nextString().toCharArray();
            for (int j = 0; j < m; j++)
                if (map[i][j] = s[j] == 'X') k++;
        }
        
        int[][] v = new int[k][];
        k = 0;
        int[] row = new int[n];
        Arrays.fill(row, -1);
        int[] col = new int[m];
        Arrays.fill(col, -1);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                if (map[i][j]) {
                    v[k++] = new int[]{i, j};
                    row[i] = j;
                    col[j] = i;
                }
        
        long ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++) {
                if (map[i][j]) {
                    ans -= sum(n-i-1)*m + sum(i)*m + sum(m-j-1)*n + sum(j)*n;
                }
                else {
                    ans += sum(n-i-1)*m + sum(i)*m + sum(m-j-1)*n + sum(j)*n;
                }
            }
        
        for (int i = 0; i < k; i++)
            ans += 4*v[i][0]*(n-v[i][0]-1) + 4*v[i][1]*(m-v[i][1]-1);
        
        for (int i = 0; i < n-1; i++) {
            if (row[i] == -1) continue;
            int dir = row[i+1] < row[i] ? -1 : 1;
            for (int j = i+1; j < n; j++) {
                if (row[j] == -1) break;
                if (dir == -1) {
                    if (row[j] > row[j-1]) break;
                    ans += 4*row[j]*(m-row[i]-1);
                }
                else if (dir == 1) {
                    if (row[j] < row[j-1]) break;
                    ans += 4*row[i]*(m-row[j]-1);
                }
            }
        }
        
        for (int i = 0; i < m-1; i++) {
            if (col[i] == -1) continue;
            int dir = col[i+1] < col[i] ? -1 : 1;
            for (int j = i+1; j < m; j++) {
                if (col[j] == -1) break;
                if (dir == -1) {
                    if (col[j] > col[j-1]) break;
                    ans += 4*col[j]*(n-col[i]-1);
                }
                else if (dir == 1) {
                    if (col[j] < col[j-1]) break;
                    ans += 4*col[i]*(n-col[j]-1);
                }
            }
        }
        
        for (int i = 0; i < k; i++)
            for (int j = i+1; j < k; j++)
                ans += 2*dist(v[i], v[j]);
        
        long t = (n*m - k);
        t *= t;
        out.println(String.format(Locale.US, "%.9f", 1.0*ans/t));
        
        out.flush();
    }

    static long sum(int x) {
        return 1L*x*(x+1)/2;
    }
    
    static int dist(int[] a, int[] b) {
        return Math.abs(a[0] - b[0]) + Math.abs(a[1] - b[1]);
    }
}