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.io.*;
import java.util.*;
import java.math.*;
import java.text.*;
public class Main
{
//private static long startTime = System.currentTimeMillis();

static int n,m,mod=1000000007,diag_one_start,diag_two_start,diag_one_x,diag_one_y,diag_two_x,diag_two_y,offset1=1000000,offset2=1000;
static int[][] grid;
static int[][][] dp;



public static void compute_DP_Table1(int loop)
{
int x1,y1,x2,y2,key,val=0,cur;



    for(int l=1;l<loop;l++)
    {
        for(x1=diag_one_x,y1=diag_one_y;x1<m && y1>=0;x1++,y1--)
        {
            for(x2=diag_two_x,y2=diag_two_y;x2<m && y2>=0;x2++,y2--)
            {
                if(x2<x1 || y2<y1)
                    continue;

                val=dp[x1][x2][0];




                if(x1-1>=0 && x2+1<m)
                {
                    
                    if(grid[y1][x1-1]==grid[y2][x2+1])
                    {
                        dp[x1-1][x2+1][1]+=val;
                        if(dp[x1-1][x2+1][1]>=mod)
                            dp[x1-1][x2+1][1]-=mod;
                    }

                }
                if(x1-1>=0 && y2+1<n)
                {
                    if(grid[y1][x1-1]==grid[y2+1][x2])
                    {
                        dp[x1-1][x2][1]+=val;
                        if(dp[x1-1][x2][1]>=mod)
                            dp[x1-1][x2][1]-=mod;
                    }

                }
                if(y1-1>=0 && x2+1<m)
                {

                    if(grid[y1-1][x1]==grid[y2][x2+1])
                    {
                        
                        dp[x1][x2+1][1]+=val;
                        if(dp[x1][x2+1][1]>=mod)
                            dp[x1][x2+1][1]-=mod;
                    }
                    
                }
                if(y1-1>=0 && y2+1<n)
                {

                    if(grid[y1-1][x1]==grid[y2+1][x2])
                    { 
                        dp[x1][x2][1]+=val;
                        if(dp[x1][x2][1]>=mod)
                            dp[x1][x2][1]-=mod;
                    }
                }
            }
        }



        diag_one_start--;
        diag_two_start++;

        if(diag_one_start<=n)
        {
            diag_one_x=0;
            diag_one_y=diag_one_start-1;
        }
        else
        {
            diag_one_x=diag_one_start-n;
            diag_one_y=n-1;
        }


        if(diag_two_start<=n)
        {
            diag_two_x=0;
            diag_two_y=diag_two_start-1;
        }
        else
        {
            diag_two_x=diag_two_start-n;
            diag_two_y=n-1;
        }



        for(x1=diag_one_x,y1=diag_one_y;x1<m && y1>=0;x1++,y1--)
        {
            for(x2=diag_two_x,y2=diag_two_y;x2<m && y2>=0;x2++,y2--)
            {

                dp[x1][x2][0]=dp[x1][x2][1];
                dp[x1][x2][1]=0;

            }
        }


    }
}


public static void determine_Diagonal_Startings()
{
    int total=n+m-1;
    if(total%2==0)
    {
        diag_one_start=(total+1)/2;
        diag_two_start=diag_one_start+1;
    }
    else
    {
        diag_one_start=(total+1)/2;
        diag_two_start=diag_one_start;
    }



    if(diag_one_start<=n)
    {
        diag_one_x=0;
        diag_one_y=diag_one_start-1;
    }
    else
    {
        diag_one_x=diag_one_start-n;
        diag_one_y=n-1;
    }


    if(diag_two_start<=n)
    {
        diag_two_x=0;
        diag_two_y=diag_two_start-1;
    }
    else
    {
        diag_two_x=diag_two_start-n;
        diag_two_y=n-1;
    }
}




@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException 
{
//BufferedReader in = new BufferedReader(new FileReader(".\\mmk\\input.txt"));
//PrintWriter out=new PrintWriter("output.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));


int i,j,x1,y1,x2,y2,dist1,dist2,dist,key,ans;




String str=in.readLine().trim();
String[] token=str.split(" ");

n=Integer.parseInt(token[0]);
m=Integer.parseInt(token[1]);


grid=new int[n][m];
dp=new int[m][m][2];


for(i=0;i<n;i++)
{
    str=in.readLine().trim();

    for(j=0;j<m;j++)
    {
        grid[i][j]=(int)str.charAt(j)-96;
    }
}




diag_one_start=-1;
diag_two_start=-1;

determine_Diagonal_Startings();


for(x1=diag_one_x,y1=diag_one_y;x1<m && y1>=0;x1++,y1--)
    {
        for(x2=0;x2<m;x2++)
        {
            
            dist1=x1+y1;
            dist2=dist1;
            y2=(n-1)-dist2+(m-1-x2);

            if( (y2>=0 && y2<n))
            {
                if(x1<=x2 && y1<=y2)
                {
                    dist=x2-x1+y2-y1;

                    if(dist<=1)
                    {
                        if(grid[y1][x1]==grid[y2][x2])
                        {
                            dp[x1][x2][0]=1;
                        } 
                    }
                }
            }
        }
    }




compute_DP_Table1(diag_one_start);
System.out.println(dp[0][m-1][0]);




// At the end
//long endTime = System.currentTimeMillis();
//System.out.println("\n\nIt took " + (endTime - startTime) + " milliseconds");



out.flush();
out.close();
}
}