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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1200;
long long row[MAX], col[MAX];
long long sol1[MAX][MAX];
long long soltt[MAX];
long long sol2[MAX];
long long n, m;
char mm[MAX][MAX];
int main() {
  scanf("%lld %lld", &n, &m);
  long long cnt = 0;
  for (int i = 0; i < n; i++) scanf("%s", mm[i]);
  for (int j = 1; j <= m; j++) col[j] = -1;
  for (int i = 0; i < n; i++) {
    row[i + 1] = -1;
    for (int j = 0; j < m; j++) {
      if (mm[i][j] == 'X') row[i + 1] = j + 1, col[j + 1] = i + 1, cnt++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sol1[i][j] = (j * (j - 1)) / 2 + (m - j + 1) * (m - j) / 2;
      if (row[i] != -1) sol1[i][j] -= std::abs(j - row[i]);
    }
  }
  long long t1, t2, t3, t4, dir;
  for (int i = 1; i <= n; i++) {
    t1 = 0;
    for (int j = 1; j <= m; j++) {
      if (j != row[i]) t1 += sol1[i][j];
    }
    t2 = 0;
    if (i != 1) {
      for (int j = 1; j <= m; j++) {
        if (j != row[i]) {
          t2 += soltt[j];
        }
      }
    }
    t2 <<= 1;
    t4 = 0;
    for (int j = i - 1; j >= 1; j--) {
      if (row[j] == -1)
        t4 += (i - j) * m;
      else
        t4 += (i - j) * (m - 1);
    }
    if (row[i] == -1)
      t4 = t4 * m;
    else
      t4 = t4 * (m - 1);
    t4 <<= 1;
    if (i == 1)
      sol2[i] = t1 + t2 + t4;
    else
      sol2[i] = sol2[i - 1] + t1 + t2 + t4;
    if (i == 1)
      for (int j = 1; j <= m; j++) soltt[j] = sol1[1][j];
    else
      for (int j = 1; j <= m; j++) soltt[j] += sol1[i][j];
  }
  for (int i = 1; i <= n; i++) {
    t3 = 0;
    if (row[i] == -1)
      dir = 0;
    else if (i - 1 < 1 || row[i - 1] == -1)
      dir = 3;
    else if (row[i - 1] > row[i]) {
      dir = 2;
      long long r = i - 2;
      t3 = 2 * m - row[i] - row[i - 1];
      while (r >= 1 && row[r] != -1 && row[r] > row[r + 1])
        t3 += m - row[r], r--;
    } else if (row[i - 1] < row[i]) {
      dir = 1;
      long long r = i - 2;
      t3 = row[i] + row[i - 1] - 2;
      while (r >= 1 && row[r] != -1 && row[r] < row[r + 1])
        t3 += row[r] - 1, r--;
    }
    if (dir == 3) t3 = (row[i] - 1) * (m - row[i]) * 4;
    if (dir == 2) t3 = t3 * (row[i] - 1) * 4;
    if (dir == 1) t3 = t3 * (m - row[i]) * 4;
    if (t3) {
      sol2[n] += t3;
    }
  }
  for (int i = 1; i <= m; i++) {
    t3 = 0;
    if (col[i] == -1)
      dir = 0;
    else if (i - 1 < 1 || col[i - 1] == -1)
      dir = 3;
    else if (col[i - 1] > col[i]) {
      dir = 2;
      long long r = i - 2;
      t3 = 2 * n - col[i] - col[i - 1];
      while (r >= 1 && col[r] != -1 && col[r] > col[r + 1])
        t3 += n - col[r], r--;
    } else if (col[i - 1] < col[i]) {
      dir = 1;
      long long r = i - 2;
      t3 = col[i] + col[i - 1] - 2;
      while (r >= 1 && col[r] != -1 && col[r] < col[r + 1])
        t3 += col[r] - 1, r--;
    }
    if (dir == 3) t3 = (col[i] - 1) * (n - col[i]) * 4;
    if (dir == 2) t3 = t3 * (col[i] - 1) * 4;
    if (dir == 1) t3 = t3 * (n - col[i]) * 4;
    if (t3) {
      sol2[n] += t3;
    }
  }
  cnt = n * m - cnt;
  long long tempcnt = cnt;
  cnt = cnt * (cnt - 1);
  printf("%.12lf\n", (double)sol2[n] / (cnt + tempcnt));
  return 0;
}