Space Scramble


Due to foreseen circumstances that were well within his control, P has found himself in quite a predicament - having to solve space-bending mazes.

The maze is presented as an n x n matrix MM. P can enter the matrix from any corner of the maze, but the exit lies in the maze at a position [u][v][u][v]. At position [i][j][i][j], he can be teleported to a position M[i][j]M[i][j] away (e.g. position [i][j+M[i][j]][i][j+M[i][j]]) within the maze (i.e. no wrap around). Determine if the maze is solvable.

Input

The first line contains an integer nn, the size of the maze. The second line contains two integers u,vu, v, the position of the exit. The following nn lines contains a row in the matrix MM.

Output

TrueTrue if we can reach the exit from any of the four corners otherwise FalseFalse.

Constraints

  • 3≤n≤50003 \le n \le 5000
  • 1≤u,v≤n1 \leq u, v \leq n
  • 0≤M[i][j]≤n0 \leq M[i][j]\leq n

Example 1

Input 1
3
2 2
1 3 0
1 0 1
0 2 1
Output 1
True

Example 2

Input 2
5
3 4
3 4 0 1 2
3 2 1 4 0
4 1 3 0 2
4 2 3 0 1
0 4 2 1 3
Output 2
False

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.