Given a square table of size n \times n filled with natural numbers, we are interested in finding paths from the top-left corner to the bottom-right corner. These paths can only move right or down, never left or up. Each path will consist of 2n - 1 numbers. If the sequence of numbers along a path reads the same forwards and backwards, we call it a palindromic path.
Your task is to calculate the total number of palindromic paths in the given table.
The input begins with a single integer (2 \le n \le 100), representing the size of the table. This is followed by lines, each containing natural numbers, none exceeding , which populate the table.
Output a single number: the remainder when the total number of palindromic paths is divided by .
3
7 10 7
5 8 10
8 5 745
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 250Example 1
Example 2
In the first example, there are four palindromic paths:
right — right — down — down (7-10-5-10-7);
right — down — right — down (7-10-8-10-7);
down — right — down — right (7-5-8-5-7);
down — down — right — right (7-5-8-5-7).
In the second example, all possible paths are palindromic. Therefore, the output should be the remainder of divided by , which is .