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;
template <class T>
T abs(T x) {
  return x > 0 ? x : (-x);
}
template <class T>
T sqr(T x) {
  return x * x;
}
const int maxn = 1100;
int n, m;
char a[maxn][maxn];
char b[maxn][maxn];
int pos[maxn];
int py[maxn];
double sx[maxn], sy[maxn];
double p[maxn], q[maxn];
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
bool good(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
int d[maxn][maxn];
void bfs(int x, int y) {
  d[x][y] = 0;
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, y));
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    for (int dir = 0; dir < 4; ++dir) {
      int xx = x + dx[dir], yy = y + dy[dir];
      if (good(xx, yy) && a[xx][yy] == '.' && d[xx][yy] == -1) {
        d[xx][yy] = d[x][y] + 1;
        q.push(pair<int, int>(xx, yy));
      }
    }
  }
}
double stupid() {
  double res = 0.0, cnt = 0.0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == 'X') continue;
      memset(d, -1, sizeof(d));
      bfs(i, j);
      for (int x = 0; x < n; ++x)
        for (int y = 0; y < m; ++y)
          if (a[x][y] == '.') {
            int t = abs(i - x) + abs(j - y);
            if (d[x][y] != t) {
              fprintf(stderr, "(%d %d) - (%d %d)\n", i, j, x, y);
              if (d[x][y] != t + 2)
                cerr << "AAA! " << d[x][y] << " " << t << "\n";
            }
            res += d[x][y], cnt += 1.0;
          }
    }
  return res / cnt;
}
int main() {
  cin >> n >> m;
  memset(pos, -1, sizeof(pos));
  memset(py, -1, sizeof(py));
  double cnt = 0.0;
  for (int i = 0; i < n; ++i) {
    scanf("%s", a[i]);
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == 'X')
        pos[i] = j, py[j] = i;
      else {
        sx[i] += 1.0;
        sy[j] += 1.0;
        cnt += 1.0;
      }
    }
  }
  double res = 0.0;
  memset(p, 0, sizeof(p));
  memset(q, 0, sizeof(q));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (a[i][j] == '.') {
        if (i < py[j])
          p[j] += 1.0;
        else
          q[j] += 1.0;
      }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (i != j) res += abs(i - j) * sx[i] * sx[j];
    }
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) {
      if (i != j) res += abs(i - j) * sy[i] * sy[j];
    }
  for (int it = 0; it < 4; ++it) {
    memset(pos, -1, sizeof(pos));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j)
        if (a[i][j] == 'X') pos[i] = j;
    }
    int cur = 0;
    while (cur < n) {
      while (cur < n && pos[cur] == -1) ++cur;
      if (cur >= n) break;
      int next = cur + 1;
      while (next < n && pos[next] >= pos[next - 1]) ++next;
      --next;
      double sp = 0.0, sq = 0.0;
      for (int i = cur; i <= next; ++i) {
        p[i] = q[i] = 0.0;
        for (int j = 0; j < m; ++j)
          if (a[i][j] == '.') {
            if (j < pos[i])
              p[i] += 1.0;
            else
              q[i] += 1.0;
          }
        sq += q[i];
      }
      for (int i = cur; i <= next; ++i) {
        sp = p[i];
        sq -= q[i];
        res += 4.0 * sp * sq;
        if (it % 2 == 0) res += 4.0 * p[i] * q[i];
      }
      cur = next + 1;
    }
    for (int i = 0; i < n; ++i) {
      reverse(a[i], a[i] + m);
    }
    if (it % 2 == 1) {
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) b[j][i] = a[i][j];
      for (int i = 0; i < m; ++i)
        for (int j = 0; j < n; ++j) a[i][j] = b[i][j];
      swap(n, m);
    }
  }
  res /= cnt * cnt;
  printf("%.20lf\n", res);
  return 0;
}