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;
long long POW(long long A, long long N, long long MOD) {
  if (N == 0) return 1 % MOD;
  if (N == 1) return A % MOD;
  long long tmp = POW(A, N / 2, MOD) % MOD;
  if (N % 2)
    return ((tmp * tmp) % MOD * A % MOD) % MOD;
  else
    return (tmp * tmp) % MOD;
}
long long MUL(long long A, long long B, long long MOD) {
  long long r = 0;
  while (B) {
    r = (r + (A * (B % 2) % MOD)) % MOD;
    A = (A + A) % MOD;
    B /= 2;
  }
  return r;
}
long long GCD(long long A, long long B) { return B == 0 ? A : GCD(B, A % B); }
int dx[] = {0, -1, 0, 1, 0};
int dy[] = {-1, 0, 1, 0, -1};
template <class X, class Y>
bool minimize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x > y + eps) {
    x = y;
    return true;
  } else
    return false;
}
template <class X, class Y>
bool maximize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x + eps < y) {
    x = y;
    return true;
  } else
    return false;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const int MAXN = 505;
const long long MOD = 1e9 + 7;
int N, M;
char A[MAXN][MAXN];
vector<vector<vector<vector<int> > > > dp;
bool Inside(int x, int y) {
  if (x < 1 || y < 1 || x > N || y > M) return 0;
  return 1;
}
namespace SubtaskTRAU {
int solve(int x, int y, int u, int v) {
  if (x == u && y == v) return 1;
  if (x > u || y > v) return 0;
  if (x == u && abs(y - v) == 1) return 1;
  if (y == v && abs(x - u) == 1) return 1;
  if (dp[x][y][u][v] != -1) return dp[x][y][u][v];
  long long cur = 0;
  for (int h1 = (2), _b = (3); h1 <= _b; ++h1) {
    int nx = x + dx[h1];
    int ny = y + dy[h1];
    if (!Inside(nx, ny)) continue;
    for (int h2 = (0), _b = (1); h2 <= _b; ++h2) {
      int nu = u + dx[h2];
      int nv = v + dy[h2];
      if (!Inside(nu, nv)) continue;
      if (A[nx][ny] != A[nu][nv]) continue;
      cur += solve(nx, ny, nu, nv);
      cur %= MOD;
    }
  }
  return dp[x][y][u][v] = cur;
}
void SOLVE() {
  dp.assign(N + 5,
            vector<vector<vector<int> > >(
                M + 5, vector<vector<int> >(N + 5, vector<int>(M + 5, -1))));
  if (A[1][1] != A[N][M])
    cout << 0 << '\n';
  else
    cout << solve(1, 1, N, M) << '\n';
}
}  // namespace SubtaskTRAU
namespace SubtaskFULL {
int CALC1(int x, int step) { return step - x + 2; }
int CALC2(int x, int step) { return N - x + M - step; }
int dp[MAXN][MAXN][252];
int solve(int x, int u, int step) {
  int y = CALC1(x, step);
  int v = CALC2(u, step);
  if (x == u && y == v) return 1;
  if (x > u || y > v) return 0;
  if (x == u && abs(y - v) == 1) return 1;
  if (y == v && abs(x - u) == 1) return 1;
  if (dp[x][u][step] != -1) return dp[x][u][step];
  long long cur = 0;
  for (int h1 = (2), _b = (3); h1 <= _b; ++h1) {
    int nx = x + dx[h1];
    int ny = y + dy[h1];
    if (!Inside(nx, ny)) continue;
    for (int h2 = (0), _b = (1); h2 <= _b; ++h2) {
      int nu = u + dx[h2];
      int nv = v + dy[h2];
      if (!Inside(nu, nv)) continue;
      if (A[nx][ny] != A[nu][nv]) continue;
      cur += solve(nx, nu, step + 1);
      cur %= MOD;
    }
  }
  return dp[x][u][step] = cur;
}
void SOLVE() {
  memset(dp, -1, sizeof(dp));
  if (A[1][1] != A[N][M])
    cout << 0 << '\n';
  else
    cout << solve(1, N, 0) << '\n';
}
}  // namespace SubtaskFULL
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> N >> M;
  for (int i = (1), _b = (N); i <= _b; ++i) {
    for (int j = (1), _b = (M); j <= _b; ++j) {
      cin >> A[i][j];
    }
  }
  SubtaskFULL ::SOLVE();
  return 0;
}