A grasshopper is in a flower field. The field contains $N \cdot N$ flowers arranged in $N$ rows and $N$ columns. For each flower in the field, we know how many petals it has.

The grasshopper is initially on the flower in row $R$ and column $C$. Its goal is to visit as many flowers as possible while obeying these rules:
 - It can only jump into an adjacent row or column. If it jumps into the adjacent row, it must jump at least two columns, and if it jumps into the adjacent column, it must jump at least two rows. In other words, it can jump from flower $(r_1 , c_1)$ to flower $(r_2, c_2)$ if:
 - $|r_1 -r_2| = 1$ and $|c_1 -c_2 |> 1$ or
 - $|c_1 -c_2| = 1$ and $|r_1 -r_2 |> 1$
 - The number of petals on the next flower must be strictly larger than the number of petals on the previous flower.

Write a program that calculates the largest number of flowers the grasshopper can visit.

-----Input-----
The first line contains the integer $N$ ($1 \le N \le 1500$), the size of the field.

The second line contains integers $R$ ($1 \le R \le N$) and $C$ ($1 \le C \le N$), the grasshopper’s initial position.

The next $N$ lines contain $N$ positive integers separated by spaces, each at most $1000000$, the numbers of petals on the flowers.

-----Output-----
Output a single integer – the largest number of flowers the grasshopper can visit.

-----Examples-----
Sample Input:
4
1 1
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
Sample Output:
4

Difficulty: competition

Starter code:

Solutions: