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 INF = 0x7fffffff, SINF = 0x3f3f3f3f;
const double PI = 3.141592653589793;
const long long LINF = 0x7fffffffffffffffLL, SLINF = 0x3f3f3f3f3f3f3f3fLL;
int t1, t2, t3, t4;
int _v, _f, _c;
long long _l;
void read() {
  _c = getchar(), _v = _f = 0;
  while (_c < '0' || _c > '9') {
    if (_c == -1) {
      _f = -1;
      return;
    } else if (_c == '-') {
      _f = 1;
    }
    _c = getchar();
  }
  while (_c <= '9' && _c >= '0') {
    _v = (_v << 3) + (_v << 1) + (_c ^ 48);
    _c = getchar();
  }
  if (_f) {
    _v = -_v;
  }
}
void read_ll() {
  _c = getchar(), _l = _f = 0;
  while (_c < '0' || _c > '9') {
    if (_c == -1) {
      _f = -1;
      return;
    } else if (_c == '-') {
      _f = 1;
    }
    _c = getchar();
  }
  while (_c <= '9' && _c >= '0') {
    _l = (_l << 3) + (_l << 1) + (_c ^ 48);
    _c = getchar();
  }
  if (_f) {
    _l = -_l;
  }
}
void read_str(char* _s) {
  _v = 0, _c = getchar();
  while (_c != '\n' && _c != ' ' && _c != -1) {
    _s[_v++] = (char)_c;
    _c = getchar();
  }
  if (_c == -1) _f = -1;
}
const int MAXN = 1005, MAXM = 100005, MAXK = 100005, MOD = 1e9 + 7;
const double EPS = 1e-8;
long long c(int n, int r) { return (long long)n * (n - 1) / r; }
char grid[MAXN][MAXN], tmp[MAXN][MAXN];
int n, m;
void rotate_90() {
  memcpy(tmp, grid, sizeof(tmp));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      grid[j][n - 1 - i] = tmp[i][j];
    }
  }
  swap(n, m);
}
int place[MAXN];
long long invalid_ways() {
  memset(place, -1, sizeof(place));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == 'X') {
        place[i] = j;
        break;
      }
    }
  }
  long long a = 0;
  for (int i = 0; i < n; i++) {
    int st = place[i];
    if (!~st) {
      continue;
    }
    a += st * (m - 1 - st);
    int last = st;
    for (int j = i + 1; j < n; j++) {
      if (place[j] < last || !~place[j]) {
        break;
      }
      a += st * (m - 1 - place[j]);
      last = place[j];
    }
    last = st;
    for (int j = i - 1; j >= 0; j--) {
      if (place[j] < last || !~place[j]) {
        break;
      }
      a += st * (m - 1 - place[j]);
      last = place[j];
    }
  }
  return a;
}
int pos[MAXN][2], cnt;
int main() {
  n = (read(), _v), m = (read(), _v);
  for (int i = 0; i < n; i++) {
    scanf("%s", grid[i]);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == 'X') {
        pos[cnt][0] = i, pos[cnt][1] = j;
        cnt++;
        ans -=
            m * (c(i + 1, 2) + c(n - i, 2)) + n * (c(j + 1, 2) + c(m - j, 2));
        continue;
      }
      ans += m * (c(i + 1, 2) + c(n - i, 2)) + n * (c(j + 1, 2) + c(m - j, 2));
    }
  }
  for (int i = 0; i < cnt; i++) {
    for (int j = 0; j < cnt; j++) {
      ans += abs(pos[i][0] - pos[j][0]) + abs(pos[i][1] - pos[j][1]);
    }
  }
  ans += invalid_ways() * 4;
  rotate_90();
  ans += invalid_ways() * 4;
  printf("%.15lf\n", ans / (double)((long long)(n * m - cnt) * (n * m - cnt)));
  return 0;
}