Palindrome Path 3

No attempts yetTime limit1sMemory limit256 MB

Problem

An N×NN \times N farm grid (1N5001 \leq N \leq 500) contains uppercase letters. A calf starts at (1,1)(1,1) and moves only right or down to reach (N,N)(N,N). It gets lost whenever the letters on its path form a palindrome. Count how many palindrome paths exist, modulo 1,000,000,0071{,}000{,}000{,}007.

Input

Line 1: NN. Next NN lines: the grid rows.

Output

Print the number of palindrome paths modulo 1,000,000,0071{,}000{,}000{,}007.

Note

On the sample 4×44 \times 4 grid the answer is 1212.