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.*;

public class R316D2_E {

    public static PrintWriter outWriter;
    public static MyScanner sc;
    public static Long MOD = 1000000007L;

    public static void main(String[] args) {
        sc = new MyScanner();
        outWriter = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int m = sc.nextInt();

        String[] p = new String[n];

        for(int i = 0;i < n;i++) {
            p[i] = sc.nextLine();
        }

        int midDist = (n + m - 2) / 2;

        long[][][] dp = new long[2][n + 2][n + 2];

        if(p[0].charAt(0) == p[n - 1].charAt(m - 1)) {
            dp[0][1][n] = 1L;
        }

        long ans = 0L;
        int curr = 0;

        for(int dist = 1; dist <= midDist; dist++) {
            for(int x1 = 1; x1 <= n; x1++) {
                for(int x2 = 1; x2 <= n; x2++) {
                    int y1 = dist + 2 - x1;
                    int y2 = n + m - x2 - dist;

                    if(y1 > 0 && y1 <= m && y2 > 0 && y2 <= m && y1 <= y2 && x1 <= x2 
                        && p[x1 - 1].charAt(y1 - 1) == p[x2 - 1].charAt(y2 - 1)) {
                        dp[1 - curr][x1][x2] = madd(dp[curr][x1 - 1][x2], 
                            madd(dp[curr][x1 - 1][x2 + 1], 
                                madd(dp[curr][x1][x2], dp[curr][x1][x2 + 1])));
                    } else {
                        dp[1 - curr][x1][x2] = 0l;
                    }
                }
            }
            curr = 1 - curr;
        }

        for(int x1 = 1; x1 <= n; x1++) {
            for(int x2 = 1; x2 <= n; x2++) {
                if(dp[curr][x1][x2] > 0) {
                    ans = madd(ans, dp[curr][x1][x2]);
                }
            }
        }

        outWriter.write("" + ans);
        outWriter.close();
    }

    static long madd(long a, long b) {
        return (long)(a + b) % MOD;
    }

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            outWriter = new PrintWriter(new BufferedOutputStream(System.out));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }


}