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>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
using ll = long long;
const ll mod = 1e9 + 7;
using Graph = vector<vector<int>>;
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> v) {
  os << "( " << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<set<T>> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &v) {
  int i = 0;
  for (auto it : v) {
    if (i > 0) {
      os << ' ';
    }
    os << it;
    i++;
  }
  return os;
}
using ll = long long int;
int H, W;
bool ch(int x, int y) { return x >= 0 && x < W && y >= 0 && y < H; }
int main() {
  cin >> H >> W;
  vector<string> fi(H);
  vector<vector<vector<ll>>> memo(H, vector<vector<ll>>(H, vector<ll>(2)));
  int need_time = (H + W - 2) / 2;
  for (int i = 0; i < H; ++i) {
    char chs[504];
    scanf("%s", chs);
    string st = chs;
    fi[i] = st;
  }
  memo[0][H - 1][0] = (fi[0][0] == fi[H - 1][W - 1]) ? 1 : 0;
  for (int i = 0; i < need_time; ++i) {
    int cur = i & 1;
    int tar = cur ^ 1;
    int au = max(0, i - (W - 1));
    int ad = min(H - 1, i);
    int bd = H - 1 - au;
    int bu = H - 1 - ad;
    for (int ay = au; ay <= ad; ++ay) {
      for (int by = bu; by <= bd; ++by) {
        int ax = i - ay;
        int bx = (H + W - 2) - i - by;
        int dx[] = {1, 0};
        int dy[] = {0, 1};
        for (int away = 0; away < 2; ++away) {
          for (int bway = 0; bway < 2; ++bway) {
            int any = ay + dy[away];
            int anx = ax + dx[away];
            int bny = by - dy[bway];
            int bnx = bx - dx[bway];
            if (ch(anx, any) && ch(bnx, bny)) {
              if (fi[any][anx] == fi[bny][bnx]) {
                memo[any][bny][tar] += memo[ay][by][cur];
              }
            }
          }
        }
      }
    }
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < H; ++j) {
        memo[i][j][cur] = 0;
        memo[i][j][tar] %= mod;
      }
    }
  }
  ll answer = 0;
  if ((H + W) % 2) {
    for (int y = 0; y < H - 1; ++y) {
      int ax = need_time - y;
      if (fi[y][ax] == fi[y + 1][ax]) {
        answer += memo[y][y + 1][need_time % 2];
      }
    }
    for (int y = 0; y < H; ++y) {
      int ax = need_time - y;
      if (ch(ax + 1, y)) {
        if (fi[y][ax] == fi[y][ax + 1]) {
          answer += memo[y][y][need_time % 2];
        }
      }
    }
  } else {
    for (int y = 0; y < H; ++y) {
      answer += memo[y][y][need_time % 2];
    }
  }
  cout << answer % mod << endl;
  return 0;
}