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.*;

import java.awt.geom.Point2D;
import java.text.*;
import java.math.*;
import java.util.*;

public class Main implements Runnable {

	final String filename = "";

	public void solve() throws Exception {
//		test();
		int n = iread(), m = iread();
		int k = 0;
		int[] x = new int[1001], y = new int[1001];
		for (int i = 0; i < n; i++) {
			String s = readword();
			for (int j = 0; j < m; j++)
				if (s.charAt(j) == 'X') {
					x[k] = i;
					y[k] = j;
					k++;
				}
		}
		double ans = smart(n, m, k, x, y);
		DecimalFormat df = new DecimalFormat("0.00000000");
		out.write(df.format(ans) + "\n");
	}

	void test() {
		Random r = new Random(32167);
		int[] x = new int[10], y = new int[10];
		cycle: while (true) {
			int n = 9, m = 10;
			int k = r.nextInt(n - 1) + 2;
			for (int i = 0; i < k; i++)
				x[i] = r.nextInt(n);
			for (int i = 0; i < k; i++)
				y[i] = r.nextInt(m);
			for (int i = 0; i < k; i++)
				for (int j = i + 1; j < k; j++)
					if (Math.abs(x[i] - x[j]) <= 1
							&& Math.abs(y[i] - y[j]) <= 1 || x[i] == x[j]
							|| y[i] == y[j])
						continue cycle;
			double ans1 = dummy(n, m, k, x, y);
			double ans2 = smart(n, m, k, x, y);
			if (Math.abs(ans1 - ans2) > 1e-9) {
				System.out.println("WRONG");
				boolean[][] w = new boolean[n][m];
				for (int i = 0; i < k; i++)
					w[x[i]][y[i]] = true;
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++)
						if (w[i][j])
							System.out.print("X");
						else
							System.out.print(".");
					System.out.println();
				}
				System.out.println("dummy = " + ans1);
				System.out.println("smart = " + ans2);
				break;
			}
			System.out.println(".");
		}
	}

	double dummy(int n, int m, int k, int[] x, int[] y) {
		boolean[][] w = new boolean[n][m];
		boolean[][] was = new boolean[n][m];
		int[] dx = new int[] { 1, 0, -1, 0 }, dy = new int[] { 0, 1, 0, -1 };
		for (int i = 0; i < k; i++)
			w[x[i]][y[i]] = true;
		int[] queue = new int[n * m];
		int[][] dist = new int[n][m];
		int count = 0;
		int total = 0;
		for (int sx = 0; sx < n; sx++)
			for (int sy = 0; sy < m; sy++) {
				if (w[sx][sy])
					continue;
				int qlen = 0;
				for (int i = 0; i < n; i++)
					Arrays.fill(was[i], false);
				queue[qlen++] = sx + sy * n;
				dist[sx][sy] = 0;
				was[sx][sy] = true;
				count++;
				for (int qcur = 0; qcur < qlen; qcur++) {
					int xx = queue[qcur] % n;
					int yy = queue[qcur] / n;
					int d = dist[xx][yy];
					for (int t = 0; t < 4; t++) {
						int x1 = xx + dx[t];
						int y1 = yy + dy[t];
						if (x1 < 0 || y1 < 0 || x1 >= n || y1 >= m)
							continue;
						if (was[x1][y1])
							continue;
						if (w[x1][y1])
							continue;
						was[x1][y1] = true;
						queue[qlen++] = x1 + y1 * n;
						count++;
						dist[x1][y1] = d + 1;
						total += d + 1;
					}
				}
			}
		return total * 1.0 / count;
	}

	double smart(int n, int m, int k, int[] x, int[] y) {
		long t1 = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				t1 += Math.abs(j - i);
		long t2 = 0;
		for (int i = 0; i < m; i++)
			for (int j = 0; j < m; j++)
				t2 += Math.abs(j - i);
		long total = t1 * m * m + t2 * n * n;

		long count = (n * m - k) * (long) (n * m - k);
		for (int j = 0; j < k; j++) {
			t1 = 0;
			for (int i = 0; i < n; i++)
				t1 += Math.abs(i - x[j]);
			t2 = 0;
			for (int i = 0; i < m; i++)
				t2 += Math.abs(i - y[j]);
			total -= 2 * (t1 * m + t2 * n);
		}

		for (int i = 0; i < k; i++)
			for (int j = 0; j < k; j++)
				if (i != j)
					total += Math.abs(x[i] - x[j]) + Math.abs(y[i] - y[j]);

		for (int t = 0; t < 2; t++) {
			int temp = n;
			n = m;
			m = temp;
			for (int i = 0; i < k; i++) {
				temp = x[i];
				x[i] = y[i];
				y[i] = temp;
			}
			for (int i = 0; i < k; i++)
				for (int j = 0; j + 1 < k; j++)
					if (x[j] > x[j + 1]) {
						temp = x[j];
						x[j] = x[j + 1];
						x[j + 1] = temp;
						temp = y[j];
						y[j] = y[j + 1];
						y[j + 1] = temp;
					}

			for (int i = 0; i < k; i++) {
				for (int j = i; j < k; j++) {
					if (j != i)
						if (y[j] < y[j - 1] || x[j] - x[j - 1] != 1)
							break;
					total += 4 * y[i] * (m - y[j] - 1);
				}
				for (int j = i - 1; j >= 0; j--) {
					if (y[j] < y[j + 1] || x[j + 1] - x[j] != 1)
						break;
					total += 4 * y[i] * (m - y[j] - 1);
				}
			}
		}
		double ans = total * 1.0 / count;
		return ans;
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));
			// in = new BufferedReader(new FileReader(filename+".in"));
			// out = new BufferedWriter(new FileWriter(filename+".out"));
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int iread() throws Exception {
		return Integer.parseInt(readword());
	}

	public double dread() throws Exception {
		return Double.parseDouble(readword());
	}

	public long lread() throws Exception {
		return Long.parseLong(readword());
	}

	BufferedReader in;

	BufferedWriter out;

	public String readword() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) {
		try {
			Locale.setDefault(Locale.US);
		} catch (Exception e) {

		}
		new Thread(new Main()).start();
		// new Thread(null, new Main(), "1", 1<<25).start();
	}
}