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;
int n, m, i, j, k1, k2, sovp;
int kol[1100][1100], resl[1100][1100], resr[1100][1100], res[1100][1100 * 2];
int num[1100], nom[1100], suml[1100], sumr[1100];
long long kl, ans;
char s[1100];
double ans2, all;
int get(int a1, int b1, int a2, int b2) {
  return kol[a2][b2] - kol[a1 - 1][b2] - kol[a2][b1 - 1] + kol[a1 - 1][b1 - 1];
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%s", &s);
    for (j = 1; j <= m; j++) {
      kol[i][j] = kol[i][j - 1] + kol[i - 1][j] - kol[i - 1][j - 1];
      if (s[j - 1] != '.') {
        num[i] = j;
        nom[j] = i;
        kol[i][j]++;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (num[i] == 0) continue;
    for (j = 1; j < i; j++) {
      if (num[j] == 0) continue;
      res[i - j][num[i] - num[j] + m]++;
    }
  }
  ans = 0;
  for (i = 1; i < n; i++) {
    for (j = 1; j < m; j++) {
      kl = (n - i) * (m - j) - get(1, 1, n - i, m - j) -
           get(i + 1, j + 1, n, m) + res[i][j + m];
      kl = kl + (n - i) * (m - j) - get(1, j + 1, n - i, m) -
           get(i + 1, 1, n, m - j) + res[i][m - j];
      ans += kl * (i + j) * 2;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (num[i] == j) continue;
      ans += (m - j) * (m - j + 1) + (n - i) * (n - i + 1);
      if (num[i] > j) ans -= (num[i] - j) * 2;
      if (nom[j] > i) ans -= (nom[j] - i) * 2;
    }
  }
  if (num[n] > 0) {
    suml[n] = num[n] - 1;
    sumr[n] = m - num[n];
  }
  for (i = n - 1; i >= 1; i--) {
    if (num[i] > 0) {
      suml[i] = num[i] - 1;
      sumr[i] = m - num[i];
      if (num[i] < num[i + 1])
        sumr[i] += sumr[i + 1];
      else
        suml[i] += suml[i + 1];
    }
  }
  for (i = n; i >= 1; i--) {
    for (j = m; j >= 1; j--) {
      if (num[i] == j) continue;
      sovp = 0;
      if (num[i] > j)
        resr[i][j] += sumr[i];
      else if (num[i] > 0) {
        resl[i][j] += suml[i];
        sovp = num[i] - 1;
      }
      if (nom[j] > i) {
        resr[i][j] += n - nom[j];
        resl[i][j] += n - nom[j];
        sovp += n - nom[j];
        if (j < m) resr[i][j] += resr[nom[j]][j + 1];
        if (j > 1) resl[i][j] += resl[nom[j]][j - 1];
      }
      ans += (resl[i][j] + resr[i][j] - sovp) * 4;
    }
  }
  all = n * m - kol[n][m];
  all = all * all;
  ans2 = ans;
  cout.precision(30);
  cout << ans2 / all;
  return 0;
}