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 int_inf = 0x3f3f3f3f;
const double double_inf = 1e30;
inline int readint() {
  bool neg = 0;
  char ch, t[11];
  int k = 0;
  while ((ch = getchar()) == ' ' || ch == '\n')
    ;
  neg = ch == '-';
  ch == '-' ? neg = 1 : t[k++] = ch;
  while ((ch = getchar()) >= '0' && ch <= '9') t[k++] = ch;
  int x = 0, y = 1;
  while (k) x += (t[--k] - '0') * y, y *= 10;
  return neg ? -x : x;
}
inline void writeint(int x) {
  char t[11];
  int k = 0;
  bool neg = 0;
  if (x < 0) x = -x, neg = 1;
  while (x) t[k++] = x % 10, x /= 10;
  if (!k) putchar('0');
  if (neg) putchar('-');
  while (k) putchar(t[--k] + '0');
  putchar('\n');
}
inline void readstr(char *s) {
  char ch;
  while ((ch = getchar()) == ' ' || ch == '\n')
    ;
  *(s++) = ch;
  while ((ch = getchar()) != ' ' && ch != '\n') *(s++) = ch;
  *s = '\0';
}
inline void writestr(const char *s) {
  while (*s != '\0') putchar(*(s++));
  putchar('\n');
}
inline long long readll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int debug = 0;
const int maxn = 5e2 + 10;
const int mod = 1e9 + 7;
inline void add(int &lhs, int rhs) {
  lhs += rhs;
  if (lhs >= mod) lhs -= mod;
}
char mt[maxn][maxn];
int dp[2][maxn][maxn];
int main() {
  if (debug) freopen("in.txt", "r", stdin);
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) readstr(mt[i] + 1);
    memset(dp, (0), sizeof(dp));
    int mid = (n + m) >> 1;
    int o = 0;
    dp[o][1][n] = mt[1][1] == mt[n][m];
    for (int len = 2; len <= mid; len++) {
      o ^= 1;
      memset(dp[o], (0), sizeof(dp[o]));
      for (int r = ((1) > (len + 1 - m) ? (1) : (len + 1 - m)); r <= len; r++) {
        int c = len + 1 - r;
        int maxi = ((n + m - len) < (n) ? (n + m - len) : (n)),
            mini = ((n + 1 - len) > (1) ? (n + 1 - len) : (1));
        for (int rr = mini; rr <= maxi; rr++) {
          int rc = n + m + 1 - len - rr;
          if (mt[r][c] != mt[rr][rc]) continue;
          add(dp[o][r][rr], dp[o ^ 1][r][rr]);
          add(dp[o][r][rr], dp[o ^ 1][r][rr + 1]);
          add(dp[o][r][rr], dp[o ^ 1][r - 1][rr]);
          add(dp[o][r][rr], dp[o ^ 1][r - 1][rr + 1]);
        }
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) add(ans, dp[o][i][i]);
    if ((m + n) & 1)
      for (int i = 1; i <= n; i++) add(ans, dp[o][i][i + 1]);
    writeint(ans);
  }
  return 0;
}