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;
char input[500][500];
int output1[500][500];
int output2[500][500];
int N, M;
void read_help(int M, int N, int p) {
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> input[(1 - p) * i + p * j][(1 - p) * j + p * i];
    }
  }
}
void read_input() {
  cin >> M >> N;
  if (M > N) {
    swap(M, N);
    read_help(N, M, 1);
    return;
  }
  read_help(M, N, 0);
}
int to_diag_num(int k, int j) {
  if (k + j >= M - 1 && k + j <= N - 1) {
    return k;
  }
  if (k + j < M - 1) {
    return j;
  }
  return M - k - 1;
}
int solve() {
  int L = (M + N - 2) >> 1;
  int* o1 = &output1[0][0];
  int* o2 = &output2[0][0];
  for (int i = L; i >= 0; --i) {
    swap(o1, o2);
    fill(o2, o2 + 500 * 500, 0);
    int k = (i < M - 1 ? i : M - 1);
    int j = (i < M - 1 ? 0 : i - M + 1);
    for (; k >= 0; --k, ++j) {
      int j1 = (N - i - 1 < j) ? j : N - i - 1;
      int k1 = (N - i - 1 < j) ? M - 1 - (j - N + i + 1) : M - 1;
      for (; k1 >= k && j1 <= N - 1; ++j1, --k1) {
        if (input[k][j] == input[k1][j1]) {
          int cur1 = to_diag_num(k, j);
          int cur2 = to_diag_num(k1, j1);
          int t1 = to_diag_num(k, j + 1);
          int t2 = to_diag_num(k + 1, j);
          int t3 = to_diag_num(k1 - 1, j1);
          int t4 = to_diag_num(k1, j1 - 1);
          if ((k1 == k && j1 - j <= 1) || (k1 - k <= 1 && j1 == j)) {
            o2[500 * cur1 + cur2] = 1;
          } else {
            if (k1 - k > 1) {
              o2[500 * cur1 + cur2] =
                  (o2[500 * cur1 + cur2] + o1[500 * t2 + t3]) % 1000000007;
            }
            if (j1 - j > 1) {
              o2[500 * cur1 + cur2] =
                  (o2[500 * cur1 + cur2] + o1[500 * t1 + t4]) % 1000000007;
            }
            if (k1 - k > 0 && j1 - j > 0) {
              o2[500 * cur1 + cur2] =
                  (o2[500 * cur1 + cur2] + o1[500 * t1 + t3]) % 1000000007;
              o2[500 * cur1 + cur2] =
                  (o2[500 * cur1 + cur2] + o1[500 * t2 + t4]) % 1000000007;
            }
          }
        }
      }
    }
  }
  return o2[0];
}
int main() {
  read_input();
  cout << solve() << '\n';
  return 0;
}