An N by N flower bed has one flower in each cell. A grasshopper is standing on the flower at row R and column C. The grasshopper knows the number of petals on every flower.
The grasshopper wants to visit as many flowers as possible while following these rules.
It may jump to a flower in an adjacent row or an adjacent column. If it moves to an adjacent row, it must also jump at least two columns away. If it moves to an adjacent column, it must also jump at least two rows away. In other words, a jump from (r1, c1) to (r2, c2) is allowed only when one of the following is true:
The destination flower must have more petals than the current flower.
Find the maximum number of flowers the grasshopper can visit, including its starting flower.
The first line contains N. (1 <= N <= 1500)
The second line contains R and C, the starting row and column of the grasshopper. (1 <= R, C <= N)
Each of the next N lines contains N integers, the petal counts of the flowers. Each petal count is at most 1,000,000.
Print the maximum number of flowers the grasshopper can visit.