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.util.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;

public class Main implements Runnable {
	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintStream out;

	public void debug(String s) {
		System.out.println(s);
	}

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	char [][] symm(char [][] b) {
		int n = b.length, m = b[0].length;
		char [][] ret = new char[m][n];
		for (int i = 0; i < m; i++)
			for (int j = 0; j < n; j++) {
				ret[i][j] = b[j][i];
			}
		return ret;
	}

	long get(char [][] b) {
		int n = b.length, m = b[0].length;
     		int INF = 100000;
     		int [] h = new int[m];
     		Arrays.fill(h, INF);
     		for (int i = 0; i < n; i++) {
     			for (int j = 0; j < m; j++) {
     				if (b[i][j] == 'X') {
     					h[j] = i;
     				}
     			}
     		}

     		int [] pref = new int[m - 1];
     		for (int i = 0; i < m - 1; i++) {
     			pref[i] = i >= 1 ? pref[i - 1] : 0;
     			if (h[i] == INF || h[i + 1] == INF) continue;
     			if (h[i] > h[i + 1]) pref[i]--;
     			if (h[i] < h[i + 1]) pref[i]++;
     		}

     		long ans = 0;

     		for (int x1 = 0; x1 < m; x1++) {
     			if (h[x1] != INF) ans += 4 * h[x1] * (n - 1 - h[x1]);
     			for (int x2 = x1 + 1; x2 < m; x2++) {
     				int diff = (x2 != 0 ? pref[x2 - 1] : 0) - (x1 != 0 ? pref[x1 - 1] : 0);
     				if (diff == x2 - x1) ans += 4 * h[x1] * (n - 1 - h[x2]);
     				if (diff == x1 - x2) ans += 4 * (n - 1 - h[x1]) * h[x2];
     			}
     		}

     		return ans;
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(System.out);


			int n = nextInt(), m = nextInt();
			
			char [][] b = new char[n][m];
			for (int i = 0; i < n; i++) {
				b[i] = in.readLine().toCharArray();
			}

			int INF = 100000;
			int fi = 0;
			int [] h = new int[m];
			Arrays.fill(h, INF);
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (b[i][j] == 'X') {
						h[j] = i;
						fi++;
					}
				}
			}


			long ans = 0;
			ans += get(b);
			ans += get(symm(b));

			for (int dx = 1; dx < m; dx++) {
				ans += (long)dx * (m - dx) * 2 * n * n;
			}

			for (int dy = 1; dy < n; dy++) {
				ans += (long)dy * (n - dy) * 2 * m * m;
			}

			for (int x1 = 0; x1 < m; x1++) {
				if (h[x1] != INF) {
					int x = x1, y = h[x1];
					ans -= n * (x * (x + 1) + (m - x) * (m - x - 1));
					ans -= m * (y * (y + 1) + (n - y) * (n - y - 1));
				}
			}

			for (int x1 = 0; x1 < m; x1++)
				for (int x2 = 0; x2 < m; x2++) {
					if (h[x1] != INF && h[x2] != INF) {
						ans += abs(x1 - x2) + abs(h[x1] - h[x2]);
					}
				}
			
			long pairs = (long)(n * m - fi) * (long)(n * m - fi);
			double res = ans * 1D / pairs;
			out.println(res);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBig() {
		return new BigInteger(nextToken());
	}
}