Repair
The renovation at Vasya's home has been going on for quite some time. Now, the entire floor of Vasya's corridor is covered in dust, and it's not evenly distributed. Vasya attempted to start sweeping the floor, but, overwhelmed by the size of the corridor, wisely decided to abandon this daunting task.
Petya is planning to visit Vasya to play hyperstones. Therefore, Vasya needs to locate the game he left in the corridor. The floor of Vasya's corridor is tiled and forms a rectangle with dimensions n by m. Vasya is currently standing on the tile at coordinates (A_1, B_1), and the game is located on the tile at (A_2, B_2).
Vasya wants to reach the game as quickly as possible, but he doesn't want to stir up dust or spread it to areas he has already cleaned. Consequently, the dustier a tile is, the slower Vasya will move across it. Based on the number of days he hasn't swept each tile, Vasya has classified the tiles from 1 to 9. Thus, crossing a tile of class k will take Vasya k seconds. Additionally, when moving from a dirtier tile k_1 to a cleaner tile k_2 (k_1 > k_2) without spreading dust, Vasya will spend 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?
Input
The first line of the input file contains the numbers m, n (0 < m, n ≤ 30), as well as the coordinates of the tiles A_1, B_1, A_2, B_2 (0 < A_1, A_2 ≤ m, 0 < B_1, B_2 ≤ n).
Each of the next n rows contains m numbers ranging from 1 to 9, which indicate the class of the corresponding tile.
Output
Output the minimum time (in seconds) required for Vasya to reach the game.