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 JAVA):

Solution:

import java.util.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Main
{
  static FastScanner in = new FastScanner(System.in);
  static StringBuilder sb = new StringBuilder();
  static DecimalFormat df = new DecimalFormat();
  static int MOD = (int)1e9 + 7;
  public static void main(String[] args)
  {
    df.setMaximumFractionDigits(20);
    df.setMinimumFractionDigits(20);
    df.setRoundingMode(RoundingMode.DOWN);
    // String formatted = df.format(0.2);
    // Never sort array of primitive type
    int N = in.nextInt();
    int M = in.nextInt();
    char[][] T = new char[N][M];
    for (int i = 0; i < N; i++)
      T[i] = in.nextToken().toCharArray();
    if (N == 1 && M == 1)
    {
      System.out.println(1);
      return;
    }
    if (N > M)
    {
      char[][] S = new char[M][N];
      for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
          S[j][i] = T[i][j];
      T = S;
      int x = N;
      N = M;
      M = x;
    }
//    for (int i = 0; i < N; i++)
//      System.out.println(Arrays.toString(T[i]));
    int cur[][] = new int[N][N];
    int prev[][] = new int[N][N];
    int numsteps = N + M - 2;
    if (numsteps % 2 == 0)
    {
      for (int i = 0; i < N; i++)
        prev[i][i] = 1;
    }
    else
    {
      for (int r1 = 0; r1 < N; r1++)
      {
        int c1 = (numsteps - 1) / 2 - r1;
        if (0 <= c1 && c1 < M)
        {
          int r2, c2;
          r2 = r1;
          c2 = c1 + 1;
          if (0 <= r2 && r2 < N && 0 <= c2 && c2 < M)
          {
            if (T[r1][c1] == T[r2][c2])
              prev[r1][r2] = 1;
          }
          r2 = r1 + 1;
          c2 = c1;
          if (0 <= r2 && r2 < N && 0 <= c2 && c2 < M)
          {
            if (T[r1][c1] == T[r2][c2])
              prev[r1][r2] = 1;
          }
        }
      }
    }
    int dx1[] = {0, 1};
    int dy1[] = {1, 0};
    int dx2[] = {0, -1};
    int dy2[] = {-1, 0};
//    for (int ii = 0; ii < N; ii++)
//      System.out.println(Arrays.toString(prev[ii]));
    for (int i = numsteps / 2 - 1; i >= 0; i--)
    {
      for (int r1 = 0; r1 < N; r1++)
      {
        int c1 = i - r1;
        for (int r2 = r1; r2 < N; r2++)
        {
          int c2 = (N + M - 2 - i) - r2;
          if (c1 >= 0 && c2 >= 0 && c1 < M && c2 < M && c1 <= c2)
          {
            if (T[r1][c1] == T[r2][c2])
            {
              for (int deltai1 = 0; deltai1 < 2; deltai1++)
              for (int deltai2 = 0; deltai2 < 2; deltai2++)
              {
                int rr1 = r1 + dx1[deltai1];
                int cc1 = c1 + dy1[deltai1];
                int rr2 = r2 + dx2[deltai2];
                int cc2 = c2 + dy2[deltai2];
                if (0 <= rr1 && rr1 < N && 0 <= cc1 && cc1 < M) 
                if (0 <= rr2 && rr2 < N && 0 <= cc2 && cc2 < M) 
                if (rr1 <= rr2 && cc1 <= cc2)
                {
//            System.out.println("(" + r1 + ", " + c1 + ")");
//            System.out.println("(" + r2 + ", " + c2 + ")");
//            System.out.println("(" + rr1 + ", " + cc1 + ")");
//            System.out.println("(" + rr2 + ", " + cc2 + ")");
//            System.out.println("hello = " + prev[rr1][rr2]);
//            System.out.println();
                  cur[r1][r2] = add(cur[r1][r2],prev[rr1][rr2]);
                }
              }
            }
          }
        }
      }
      for (int ii = 0; ii < N; ii++)
      for (int jj = 0; jj < N; jj++)
      {
        prev[ii][jj] = cur[ii][jj];
        cur[ii][jj] = 0;
      }

//      System.out.println();
//      System.out.println();
//    for (int ii = 0; ii < N; ii++)
//      System.out.println(Arrays.toString(prev[ii]));
    }
    System.out.println(prev[0][N-1]);
  }
  static int add(int a, int b)
  {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
  }
  static int mul(int a, int b)
  {
    long x = a;
    x *= b;
    x %= MOD;
    return (int) x;

  }
  static BigInteger b(long n) { return BigInteger.valueOf(n);}
  static BigInteger b(String s) { return new BigInteger(s); }
  static BigDecimal bd(double d) { return BigDecimal.valueOf(d);}
  static BigDecimal bd(String s) { return new BigDecimal(s); }
}
class FastScanner
{
  BufferedReader reader;
  StringTokenizer tokenizer;
  FastScanner (InputStream inputStream)
  {
    reader = new BufferedReader(new InputStreamReader(inputStream));
  }
  String nextToken()
  {
    while (tokenizer == null || ! tokenizer.hasMoreTokens())
    {
      try {
        tokenizer = new StringTokenizer(reader.readLine());
      } catch (Exception e){}
    }
    return tokenizer.nextToken();
  }
  boolean hasNext()
  {
    if (tokenizer == null || ! tokenizer.hasMoreTokens())
    {
      try {
        tokenizer = new StringTokenizer(reader.readLine());
      } catch (Exception e){ return false; }
    }
    return true;
  }
  int nextInt()
  {
    return Integer.parseInt(nextToken());
  }
}