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 INF = 0x3f3f3f3f;
const int mod = 1000000007;
void Open() {}
char mar[510][510];
int dp[2][510][510];
int sta1[10], sta2[10];
int n, m;
void getidx1(int cen, int idx, int& x, int& y) {
  if (m >= n) {
    y = cen, x = 1;
    y -= (idx - 1), x += (idx - 1);
  } else {
    y = min(m, cen);
    if (cen <= m)
      x = 1;
    else
      x = cen - m + 1;
    x += (idx - 1), y -= (idx - 1);
  }
}
void getidx2(int cen, int idx, int& x, int& y) {
  if (m >= n) {
    x = max(n - cen + 1, 1);
    if (cen <= n)
      y = m;
    else
      y = m - (cen - n);
    x += (idx - 1), y -= (idx - 1);
  } else {
    x = n - cen + 1;
    y = m;
    x += (idx - 1), y -= (idx - 1);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", mar[i] + 1);
  if (mar[1][1] != mar[n][m]) {
    printf("0\n");
    return 0;
  }
  int cur = 0;
  dp[cur][1][1] = 1;
  for (int i = 2; i <= (n + m) / 2; i++) {
    cur ^= 1;
    memset(dp[cur], 0, sizeof(dp[cur]));
    int cn = min(i, min(n, m));
    int x1, y1, x2, y2, t1, t2;
    for (int j = 1; j <= cn; j++)
      for (int k = 1; k <= cn; k++) {
        getidx1(i, j, x1, y1);
        getidx2(i, k, x2, y2);
        if (mar[x1][y1] != mar[x2][y2]) continue;
        int tail1 = 0, tail2 = 0;
        getidx1(i - 1, j, t1, t2);
        if (((t1) > 0 && (t1) <= n && (t2) > 0 && (t2) <= m)) sta1[tail1++] = j;
        if (i <= m) {
          getidx1(i - 1, j - 1, t1, t2);
          if (((t1) > 0 && (t1) <= n && (t2) > 0 && (t2) <= m))
            sta1[tail1++] = j - 1;
        } else {
          getidx1(i - 1, j + 1, t1, t2);
          if (((t1) > 0 && (t1) <= n && (t2) > 0 && (t2) <= m))
            sta1[tail1++] = j + 1;
        }
        getidx2(i - 1, k, t1, t2);
        if (((t1) > 0 && (t1) <= n && (t2) > 0 && (t2) <= m)) sta2[tail2++] = k;
        if (i > n) {
          getidx2(i - 1, k + 1, t1, t2);
          if (((t1) > 0 && (t1) <= n && (t2) > 0 && (t2) <= m))
            sta2[tail2++] = k + 1;
        } else {
          getidx2(i - 1, k - 1, t1, t2);
          if (((t1) > 0 && (t1) <= n && (t2) > 0 && (t2) <= m))
            sta2[tail2++] = k - 1;
        }
        for (int cnt1 = 0; cnt1 < tail1; cnt1++)
          for (int cnt2 = 0; cnt2 < tail2; cnt2++)
            dp[cur][j][k] = ((long long)dp[cur][j][k] +
                             dp[cur ^ 1][sta1[cnt1]][sta2[cnt2]]) %
                            mod;
      }
  }
  long long ans = 0;
  if ((n + m) & 1) {
    int cn = min(n, m), x1, y1, x2, y2;
    for (int i = 1; i <= cn; i++) {
      if (i != cn && n < m) {
        getidx1((n + m) / 2, i, x1, y1);
        getidx2((n + m) / 2, i + 1, x2, y2);
        if (mar[x1][y1] == mar[x2][y2]) ans = (ans + dp[cur][i][i + 1]) % mod;
      }
      if (i > 1 && n > m) {
        getidx1((n + m) / 2, i, x1, y1);
        getidx2((n + m) / 2, i - 1, x2, y2);
        if (mar[x1][y1] == mar[x2][y2]) ans = (ans + dp[cur][i][i - 1]) % mod;
      }
      ans = (ans + dp[cur][i][i]) % mod;
    }
  } else {
    int cn = min(n, m);
    for (int i = 1; i <= cn; i++) ans = (ans + dp[cur][i][i]) % mod;
  }
  printf("%I64d\n", ans);
  return 0;
}