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 T[505][505];
int dp[505][505][2], m, n;
int getx(int d, int i) { return min(d, m - 1) - i; }
int gety(int d, int i) {
  int x0 = getx(d, 0);
  int y0 = d - x0;
  return y0 + i;
}
int geti(int x, int y) { return min(y, m - x - 1); }
int main() {
  int c, i, j, p;
  scanf("%d %d\n", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) scanf("%c", &T[j][i]);
    scanf("\n");
  }
  if (n > m) {
    for (i = 0; i < n; i++)
      for (j = 0; j < i; j++) swap(T[i][j], T[j][i]);
    swap(m, n);
  }
  memset(dp, 0, sizeof(dp));
  for (i = 0; i < 505; i++) dp[i][i][0] = dp[i][i][1] = 1;
  int d = n + m - 1;
  int ld, rd;
  if (d % 2 == 0) {
    ld = d / 2 - 1;
    rd = d / 2;
  } else {
    ld = d / 2 - 1;
    rd = d / 2 + 1;
  }
  for (; ld >= 0; ld--, rd++) {
    c = ld % 2;
    p = (ld + 1) % 2;
    int len = min(ld + 1, min(m, n));
    for (i = 0; i < len; i++) {
      int xl = getx(ld, i), yl = gety(ld, i);
      for (j = 0; j < len; j++) {
        int xr = getx(rd, j), yr = gety(rd, j);
        int& ans = dp[i][j][c];
        ans = 0;
        if (T[xl][yl] == T[xr][yr]) {
          if (rd == ld + 1) {
            if ((xr == xl + 1 && yr == yl) || (yr == yl + 1 && xr == xl))
              ans = 1;
          } else {
            if (yr && T[xl + 1][yl] == T[xr][yr - 1])
              ans = (ans + dp[geti(xl + 1, yl)][geti(xr, yr - 1)][p]) %
                    1000000007;
            if (T[xl + 1][yl] == T[xr - 1][yr])
              ans = (ans + dp[geti(xl + 1, yl)][geti(xr - 1, yr)][p]) %
                    1000000007;
            if (yl < n - 1 && yr && T[xl][yl + 1] == T[xr][yr - 1])
              ans = (ans + dp[geti(xl, yl + 1)][geti(xr, yr - 1)][p]) %
                    1000000007;
            if (yl < n - 1 && T[xl][yl + 1] == T[xr - 1][yr])
              ans = (ans + dp[geti(xl, yl + 1)][geti(xr - 1, yr)][p]) %
                    1000000007;
          }
        }
      }
    }
  }
  printf("%d\n", dp[0][0][c]);
}