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.util.Map.Entry;
import java.io.*;
import java.lang.*;
import java.math.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	final int MOD = (int)(1e9) + 7;
	
	boolean check(int i, int n) {
		return 0 <= i && i < n;
	}
	
    void solve() throws Exception {
    	int n = sc.nextInt();
    	int m = sc.nextInt();
    	int[][] a = new int[n][m];
    	for (int i = 0; i < n; i++) {
    		String s = sc.nextToken();
    		for (int j = 0; j < m; j++) {
    			a[i][j] = s.charAt(j) - 'a';
    		}
    	}
    	int N = max(n, m) + 1;
    	int[][][] dp = new int[2][N][N];
    	if (a[0][0] == a[n - 1][m - 1]) {
    		dp[0][0][0] = 1;
    	} else {
    		out.println(0);
    		return;
    	}
    	for (int move = 0; move < (n + m - 2) / 2; move++) {
    		int X = (move & 1);
    		int Y = (X ^ 1);
    		for (int i = 0; i < N; i++) {
    			for (int j = 0; j < N; j++) {
    				dp[Y][i][j] = 0;
    			}
    		}
    		for (int d1 = 0; d1 < N; d1++) {
    			int i1 = d1;
    			int j1 = move - d1;
    			if (check(i1, n) && check(j1, m)) {
    				for (int d2 = 0; d2 < N; d2++) {
    					int i2 = n - 1 - move + d2;
    					int j2 = m - 1 - d2;
    					if (check(i2, n) && check(j2, m)) {
    						if (dp[X][d1][d2] > 0) {
    							if (check(j1 + 1, m)) {
    								int d11 = d1;
    								if (check(j2 - 1, m) && a[i1][j1 + 1] == a[i2][j2 - 1]) {
    									int d22 = d2 + 1;
    									dp[Y][d11][d22] += dp[X][d1][d2];
    									if (dp[Y][d11][d22] >= MOD) {
    										dp[Y][d11][d22] -= MOD;
    									}
    								}
    								if (check(i2 - 1, n) && a[i1][j1 + 1] == a[i2 - 1][j2]) {
    									int d22 = d2;
    									dp[Y][d11][d22] += dp[X][d1][d2];
    									if (dp[Y][d11][d22] >= MOD) {
    										dp[Y][d11][d22] -= MOD;
    									}
    								}
    							}
    							if (check(i1 + 1, n)) {
    								int d11 = d1 + 1;
    								if (check(j2 - 1, m) && a[i1 + 1][j1] == a[i2][j2 - 1]) {
    									int d22 = d2 + 1;
    									dp[Y][d11][d22] += dp[X][d1][d2];
    									if (dp[Y][d11][d22] >= MOD) {
    										dp[Y][d11][d22] -= MOD;
    									}
    								}
    								if (check(i2 - 1, n) && a[i1 + 1][j1] == a[i2 - 1][j2]) {
    									int d22 = d2;
    									dp[Y][d11][d22] += dp[X][d1][d2];
    									if (dp[Y][d11][d22] >= MOD) {
    										dp[Y][d11][d22] -= MOD;
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    	}
    	int move = (n + m - 2) / 2;
    	int X = (move & 1);
    	int ans = 0;
    	for (int d1 = 0; d1 < N; d1++) {
    		int i1 = d1;
			int j1 = move - d1;
			if (check(i1, n) && check(j1, m)) {
	    		for (int d2 = 0; d2 < N; d2++) {
	    			int i2 = n - 1 - move + d2;
					int j2 = m - 1 - d2;
					if (check(i2, n) && check(j2, m)) {
						if (abs(i2 - i1) + abs(j2 - j1) < 2) {
							ans += dp[X][d1][d2];
							if (ans >= MOD) {
								ans -= MOD;
							}
						}
					}
	    		}
			}
    	}
    	out.println(ans);
    }
    
    BufferedReader in;
    PrintWriter out;
    FastScanner sc;
    
    final String INPUT_FILE = "stdin";
    final String OUTPUT_FILE = "stdout";
    
    static Throwable throwable;
    
    public static void main(String[] args) throws Throwable {
        Thread thread = new Thread(null, new Solution(), "", (1 << 26));
        thread.start();
        thread.join();
        thread.run();
        if (throwable != null)
            throw throwable;
    }
    
    
    public void run() {
        try {
            if (INPUT_FILE.equals("stdin"))
                in = new BufferedReader(new InputStreamReader(System.in));
            else
                in = new BufferedReader(new FileReader(INPUT_FILE));
            if (OUTPUT_FILE.equals("stdout"))
                out = new PrintWriter(System.out);
            else
                out = new PrintWriter(new FileWriter(OUTPUT_FILE));
            sc = new FastScanner(in);
            solve();
        } catch (Exception e) {
            throwable = e;
        } finally {
            out.close();
        }
    }
}

class FastScanner {
    BufferedReader reader;
    StringTokenizer strTok;
    
    FastScanner(BufferedReader reader) {
        this.reader = reader;
    }
    
    public String nextToken() throws Exception {
        while (strTok == null || !strTok.hasMoreTokens())
            strTok = new StringTokenizer(reader.readLine());
        return strTok.nextToken();
    }
    
    public boolean EOF() throws Exception {
    	if (strTok != null && strTok.hasMoreTokens()) {
    		return false;
    	} else {
    		String line = reader.readLine();
    		if (line == null)
    			return true;
    		strTok = new StringTokenizer(line);
    		return false;
    	}
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}