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.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by Ilya Sergeev on 13.08.2015.
 */
public class eLab {
    public static long labyrinth2(int y1, int x1, int y2, int x2, int ySize, int xSize, String[][] labyrinthOld) {
        List<String>[][] labyrinth = new ArrayList[ySize][xSize];
        for(int j = y2; j>= 0; j--) {
            for (int i = xSize - 2; i >= 0; i--) {
                labyrinth[j][i] = new ArrayList<>();
                labyrinth[j][i].add(labyrinthOld[j][i]);
            }
        }
        for(int j = x2; j >=0;j--) {
            for (int i = ySize - 1; i >= 0; i--) {
                labyrinth[i][j] = new ArrayList<>();
                labyrinth[i][j].add(labyrinthOld[i][j]);
            }
        }
        for (int i = xSize - 2; i >= 0; i--) {
            labyrinth[y2][i].set(0,labyrinth[y2][i].get(0)+labyrinth[y2][i+1].get(0));
        }
        for (int i = ySize-2; i >= 0; i--) {
            labyrinth[i][x2].set(0,labyrinth[i][x2].get(0)+labyrinth[i+1][x2].get(0));
        }
        for (int y = ySize-2, x = xSize - 2; y >=0 && x >= 0; y--, x--) {
            for (int i = x; i >= 0; i--) {
                String old = labyrinth[y][i].remove(0);
                for(int i1 = 0; i1 < labyrinth[y + 1][i].size(); i1++){
                    labyrinth[y][i].add(old+labyrinth[y+1][i].get(i1));
                }
                for(int i1 = 0; i1 < labyrinth[y][i+1].size(); i1++){
                    labyrinth[y][i].add(old+labyrinth[y][i+1].get(i1));
                }
                //labyrinth[y][i] = labyrinth[y][i]+ Math.max(labyrinth[y - 1][i], labyrinth[y][i + 1]);
            }
            for (int i = y-1; i >= 0; i--) {
                String old = labyrinth[i][x].remove(0);
                for(int i1 = 0; i1 < labyrinth[i + 1][x].size(); i1++){
                    labyrinth[i][x].add(old+labyrinth[i+1][x].get(i1));
                }
                for(int i1 = 0; i1 < labyrinth[i][x+1].size(); i1++){
                    labyrinth[i][x].add(old+labyrinth[i][x+1].get(i1));
                }
                //labyrinth[i][x] =labyrinth[i][x]+ Math.max(labyrinth[i - 1][x], labyrinth[i][x + 1]);
            }
            for (int i = x+1; i >= 0; i--) {
                labyrinth[y+1][i] = null;
            }
            for (int i = y+1; i >= 0; i--) {
                labyrinth[i][x+1] = null;
            }
        }
        long count = 0;
        for(String s : labyrinth[0][0]) if(s.length() == xSize+ySize -1 && isPalindrome(s,0,s.length()-1)) count++;
        return count % (long)(Math.pow(10,9)+7);
    }

    public static boolean isPalindrome(String a, int l,int r){
        if(l >= r) return true;
        if(a.charAt(l) == a.charAt(r)) return isPalindrome(a,++l,--r);
        return false;
    }

    private final int MOD = (int) 1e9 + 7;

    public void solve() {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int W = scanner.nextInt();

        int N = Math.max(H, W) + 10;
        char[][] map = new char[N][N];
        for (int i = 1; i <= H; i++) {
            char[] str = scanner.next().toCharArray();
            for (int j = 1; j <= W; j++) {
                map[i][j] = str[j - 1];
            }
        }
        scanner.close();

        int[][] dp = new int[N][N];


        int MOVES = H + W - 2;
        MOVES /= 2;
        for (int h = 1; h <= H; h++) {
            int w = MOVES - h + 2;

            for (int rh = 1; rh <= H; rh++) {
                int rw = W - (MOVES - (H - rh));
                if (w < 0 || rw < 0 || w >= N || rw >= N) {

                    continue;
                }
                if (h > rh || w > rw) {

                    dp[h][rh] = 0;
                } else if (map[h][w] != map[rh][rw]) {

                    dp[h][rh] = 0;
                } else {
                    dp[h][rh] = 1;
                }
            }
        }

        int[][] next = new int[N][N];
        for (int m = MOVES - 1; m >= 0; m--) {
            // ッ
            for (int h = 1; h <= H; h++) {
                int w = m - h + 2;

                for (int rh = 1; rh <= H; rh++) {
                    int rw = W - (m - (H - rh));
                    if (w < 0 || rw < 0 || w >= N || rw >= N) {

                        continue;
                    }

                    if (h > rh || w > rw) {
                        next[h][rh] = 0;
                    } else if (map[h][w] != map[rh][rw]) {
                        next[h][rh] = 0;
                    } else {
                        long tmp = (long) dp[h][rh] + dp[h][rh - 1]
                                + dp[h + 1][rh] + dp[h + 1][rh - 1];
                        tmp %= MOD;
                        next[h][rh] = (int) tmp;
                    }
                }
            }

            for (int h = 1; h <= H; h++) {
                for (int rh = 1; rh <= H; rh++) {
                    dp[h][rh] = next[h][rh];
                }
            }
        }
        System.out.println(dp[1][H]);

    }


    public static void main(String[] args){
        /*int n,m;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        if(1<=n && m<=500){
            String[][] mass = new String[n][m];
            for(int i = 0; i < n; i++){
                String t = sc.next();
                for(int j = 0; j < m; j++){
                    mass[i][j] = String.valueOf(t.charAt(j));
                }
            }
            System.out.println(labyrinth2(0, 0, n - 1, m - 1, n, m, mass));
            // System.out.println();
        } */
        new eLab().solve();

    }
}