
The renovation at Vasya's home has dragged on for quite some time. Now, the entire floor of Vasya's corridor is covered in dust, and it is not distributed evenly. At some places, Vasya tried to start sweeping, but, discouraged by the size of the corridor, he wisely decided to abandon this hopeless task.
Petya plans to visit Vasya to play hyperstones. Therefore, Vasya needs to locate the game he left behind in the corridor. The floor of Vasya's corridor is tiled and forms a rectangle of size by . Vasya is currently standing on the tile at coordinates (A_1, B_1), and the game is located on the tile at coordinates (A_2, B_2).
Vasya wants to reach the game as quickly as possible, but he does not want to stir up dust or spread it into areas he has already cleaned. Therefore, the dustier a tile is, the slower Vasya will move across it. Knowing how many days he has not swept each tile, Vasya classified the tiles into classes from to . Crossing a tile of class requires seconds for Vasya. In addition, before stepping from a dirtier tile k_1 to a cleaner tile k_2 (k_1 > k_2) without spreading dust, Vasya spends exactly (k_1 - k_2) seconds shaking his slippers. To avoid confusion, Vasya will only move from one tile to another if they share a side.
How much time does Vasya need to reach the game?
The first line contains the numbers , (0 < m, n \leq 30), and the coordinates of the tiles A_1, B_1, A_2, B_2 (0 < A_1, A_2 \leq m, 0 < B_1, B_2 \leq n).
Each of the next rows contains numbers from to , indicating the class of the corresponding tile.
Print the minimum time (in seconds) Vasya needs to reach the game.
Example 1