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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author t.me/musin_acm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        int n;
        int m;
        char[][] a;
        int mod = (int) 1e9 + 7;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            m = in.readInt();
            a = new char[n][];
            for (int i = 0; i < n; i++) {
                a[i] = in.next().toCharArray();
            }

            int pathLen = (n + m - 2) / 2;
            int[][] prevDp = new int[n][n];
            int[][] curDp = new int[n][n];
            for (int i = 0; i < n; i++) {
                int j = pathLen - i;
                if (inside(i, j)) {
                    if ((n + m) % 2 == 0) {
                        curDp[i][i]++;
                    } else {
                        if (j + 1 < m && a[i][j] == a[i][j + 1]) {
                            curDp[i][i]++;
                        }
                        if (i + 1 < n && a[i][j] == a[i + 1][j]) {
                            curDp[i][i + 1]++;
                        }
                    }
                }
            }
            for (int i = pathLen - 1; i >= 0; i--) {
                int[][] t = prevDp;
                prevDp = curDp;
                curDp = t;
                ArrayUtils.fill(curDp, 0);
                for (int x1 = 0; x1 < n; x1++) {
                    int y1 = i - x1;
                    if (!inside(x1, y1)) {
                        continue;
                    }
                    for (int x2 = 0; x2 < n; x2++) {
                        int y2 = coord(i, x2);
                        if (!inside(x2, y2)) {
                            continue;
                        }
                        if (a[x1][y1] != a[x2][y2]) {
                            continue;
                        }
                        if (x1 + 1 < n) {
                            if (x2 - 1 >= 0 && x1 + 1 <= x2 - 1 && y1 <= y2) {
                                upd(prevDp, curDp, x1 + 1, x2 - 1, x1, x2);
                            }
                            if (y2 - 1 >= 0 && x1 + 1 <= x2 && y1 <= y2 - 1) {
                                upd(prevDp, curDp, x1 + 1, x2, x1, x2);
                            }
                        }
                        if (y1 + 1 < m) {
                            if (x2 - 1 >= 0 && x1 <= x2 - 1 && y1 + 1 <= y2) {
                                upd(prevDp, curDp, x1, x2 - 1, x1, x2);
                            }
                            if (y2 - 1 >= 0 && x1 <= x2 && y1 + 1 <= y2 - 1) {
                                upd(prevDp, curDp, x1, x2, x1, x2);
                            }
                        }
                    }
                }
            }

            int ans = curDp[0][n - 1];
            out.print(ans);
        }

        void upd(int[][] prev, int[][] cur, int x10, int x20, int x11, int x21) {
            cur[x11][x21] = add(cur[x11][x21], prev[x10][x20]);
        }

        int add(int a, int b) {
            int c = a + b;
            if (c >= mod) {
                c -= mod;
            }
            return c;
        }

        int coord(int d, int value) {
            return n + m - 2 - value - d;
        }

        boolean inside(int x, int y) {
            return 0 <= x && x < n && 0 <= y && y < m;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void print(int i) {
            writer.print(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class ArrayUtils {
        public static void fill(int[][] array, int value) {
            for (int[] row : array) {
                Arrays.fill(row, value);
            }
        }

    }
}