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 M = 1000 + 5;
char a[M][M];
struct NODE {
  int row;
  int col;
} node[M];
int ROW[1005];
int COL[1005];
long long int ans = 0;
int n, m;
void check_row(int r) {
  if (ROW[r] == -1) return;
  double sum1 = m - ROW[r] - 1;
  for (int i = r + 1; i < n; i++) {
    if (ROW[i] == -1) break;
    if (ROW[i] < ROW[i - 1]) break;
    sum1 += m - ROW[i] - 1;
  }
  for (int i = r - 1; i >= 0; i--) {
    if (ROW[i] == -1) break;
    if (ROW[i] < ROW[i + 1]) break;
    sum1 += m - ROW[i] - 1;
  }
  sum1 *= ROW[r] * 2;
  double sum2 = ROW[r];
  for (int i = r + 1; i < n; i++) {
    if (ROW[i] == -1) break;
    if (ROW[i] > ROW[i - 1]) break;
    sum2 += ROW[i];
  }
  for (int i = r - 1; i >= 0; i--) {
    if (ROW[i] == -1) break;
    if (ROW[i] > ROW[i + 1]) break;
    sum2 += ROW[i];
  }
  sum2 *= (m - ROW[r] - 1) * 2;
  ans += sum1 + sum2;
}
void check_column(int c) {
  if (COL[c] == -1) return;
  double sum1 = n - COL[c] - 1;
  for (int i = c + 1; i < m; i++) {
    if (COL[i] == -1) break;
    if (COL[i] < COL[i - 1]) break;
    sum1 += n - COL[i] - 1;
  }
  for (int i = c - 1; i >= 0; i--) {
    if (COL[i] == -1) break;
    if (COL[i] < COL[i + 1]) break;
    sum1 += n - COL[i] - 1;
  }
  sum1 *= COL[c] * 2;
  double sum2 = COL[c];
  for (int i = c + 1; i < m; i++) {
    if (COL[i] == -1) break;
    if (COL[i] > COL[i - 1]) break;
    sum2 += COL[i];
  }
  for (int i = c - 1; i >= 0; i--) {
    if (COL[i] == -1) break;
    if (COL[i] > COL[i + 1]) break;
    sum2 += COL[i];
  }
  sum2 *= (n - COL[c] - 1) * 2;
  ans += sum1 + sum2;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int col = 0; col < m; col++) {
    for (int icol = col + 1; icol < m; icol++) {
      ans = ans + (icol - col) * 2 * n * n;
    }
  }
  for (int row = 0; row < n; row++) {
    for (int irow = row + 1; irow < n; irow++) {
      ans = ans + (irow - row) * 2 * m * m;
    }
  }
  int num = 0;
  for (int row = 0; row < n; row++) {
    for (int col = 0; col < m; col++) {
      if (a[row][col] == 'X') {
        node[num].row = row;
        node[num].col = col;
        num++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    ROW[i] = -1;
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'X') {
        ROW[i] = j;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    COL[i] = -1;
    for (int j = 0; j < n; j++) {
      if (a[j][i] == 'X') {
        COL[i] = j;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) check_row(i);
  for (int i = 0; i < m; i++) check_column(i);
  for (int i = 0; i < num; i++) {
    long long int ans1 = 0;
    int col1 = node[i].col;
    int col2 = m - 1 - col1;
    ans1 = ans1 + n * (col1 + 1) * col1 / 2 + n * (col2 + 1) * col2 / 2;
    int row1 = node[i].row;
    int row2 = n - 1 - row1;
    ans1 = ans1 + m * (row1 + 1) * row1 / 2 + m * (row2 + 1) * row2 / 2;
    ans = ans - ans1 * 2;
  }
  for (int i = 0; i < num; i++) {
    for (int j = i + 1; j < num; j++) {
      int dis1 = node[i].row - node[j].row;
      if (dis1 < 0) dis1 = -dis1;
      int dis2 = node[i].col - node[j].col;
      if (dis2 < 0) dis2 = -dis2;
      ans = ans + 2 * (dis1 + dis2);
    }
  }
  double fans = ans;
  printf("%.20f\n", fans / (n * m - num) / (n * m - num));
  return 0;
}