Problem: Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote the cell at the intersection of the r-th row and the c-th column as (r, c).

Initially the pig stands in cell (1, 1), and in the end she wants to be in cell (n, m). Since the pig is in a hurry to get home, she can go from cell (r, c), only to either cell (r + 1, c) or (r, c + 1). She cannot leave the forest.

The forest, where the pig is, is very unusual. Some cells of the forest similar to each other, and some look very different. Peppa enjoys taking pictures and at every step she takes a picture of the cell where she is now. The path through the forest is considered to be beautiful if photographs taken on her way, can be viewed in both forward and in reverse order, showing the same sequence of photos. More formally, the line formed by the cells in order of visiting should be a palindrome (you can read a formal definition of a palindrome in the previous problem).

Count the number of beautiful paths from cell (1, 1) to cell (n, m). Since this number can be very large, determine the remainder after dividing it by 109 + 7.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field.

Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.

Output

Print a single integer — the number of beautiful paths modulo 109 + 7.

Examples

Input

3 4
aaab
baaa
abba


Output

3

Note

Picture illustrating possibilities for the sample test. 

<image>

<image>

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, m;
char grid[600][600];
vector<int> save[1200][2];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int dp[2][1200][1200];
int f[600 * 600][2];
void liinit(int step, int rev) {
  for (int i = 0; i < save[step][0].size(); i++) {
    for (int j = 0; j < save[step][1].size(); j++) {
      dp[rev][i][j] = 0;
    }
  }
}
void init() {
  for (int i = 0; i < 1200; i++) {
    for (int j = 0; j < 2; j++) save[i][j].clear();
  }
  memset(dp, 0, sizeof(dp));
  memset(f, 0, sizeof(f));
}
int main() {
  while (cin >> n >> m) {
    init();
    for (int i = 0; i < n; i++) {
      scanf("%s", grid[i]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        save[i + j][0].push_back(i * m + j);
        save[abs(n - 1 - i) + abs(m - 1 - j)][1].push_back(i * m + j);
        f[i * m + j][0] = save[i + j][0].size() - 1;
        f[i * m + j][1] = save[abs(n - 1 - i) + abs(m - 1 - j)][1].size() - 1;
      }
    }
    for (int i = 0; i <= (n - 1 + m - 1) / 2; i++) {
      sort(save[i][0].begin(), save[i][0].end());
      sort(save[i][1].begin(), save[i][1].end());
    }
    int mode = ((n - 1 + m - 1) % 2 == 0 ? 0 : 1);
    int rev = 0;
    int ans = 0;
    if (grid[0][0] == grid[n - 1][m - 1]) {
      dp[rev][0][0] = 1;
    } else {
      printf("0\n");
      continue;
    }
    for (int step = 0; step <= (n - 1 + m - 1) / 2; step++) {
      liinit(step + 1, rev ^ 1);
      bool finish = false;
      for (int i = 0; i < save[step][0].size(); i++) {
        int s1 = save[step][0][i];
        for (int j = 0; j < save[step][1].size(); j++) {
          int s2 = save[step][1][j];
          int nx1 = s1 / m;
          int ny1 = s1 % m;
          int nx2 = s2 / m;
          int ny2 = s2 % m;
          if (mode == 0) {
            if (s1 == s2) {
              ans += dp[rev][i][j];
              ans %= mod;
              finish = 1;
            }
          } else if (mode == 1) {
            if ((abs(nx1 - nx2) + abs(ny1 - ny2) == 1) &&
                grid[nx1][ny1] == grid[nx2][ny2]) {
              ans += dp[rev][i][j];
              ans %= mod;
              finish = 1;
            }
          }
          for (int ii = 0; ii < 2; ii++) {
            int tx1 = nx1 + dir[ii][0];
            int ty1 = ny1 + dir[ii][1];
            if (tx1 < 0 || tx1 >= n || ty1 < 0 || ty1 >= m) continue;
            for (int jj = 2; jj < 4; jj++) {
              int tx2 = nx2 + dir[jj][0];
              int ty2 = ny2 + dir[jj][1];
              if (tx2 < 0 || tx2 >= n || ty2 < 0 || ty2 >= m) continue;
              if (grid[tx1][ty1] != grid[tx2][ty2]) continue;
              int idx1 = f[tx1 * m + ty1][0];
              int idx2 = f[tx2 * m + ty2][1];
              dp[rev ^ 1][idx1][idx2] += dp[rev][i][j];
              dp[rev ^ 1][idx1][idx2] %= mod;
            }
          }
        }
      }
      if (finish == 1) break;
      rev ^= 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}