378. Save the Fisher

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



Peter has a boat. He loves to use it for fishing on the Berland Lake. But today an accident happen with him. A huge fish ate the hook, and when Peter tried to take the fish out of the lake, he suddenly discovered that the fish was stronger. Unfortunately Peter was unable to stay on the board and he fell down into the water. But he did not want to lose such a catch. So the fish took him somewhere...

The Peter is now somewhere inside the lake and lost his boat and his rod. Luckily, Peter knows each bermeter of this lake (bermeter is the length measurement unit in Berland). You will help Peter to create the plan to save himself.

The lake is a rectangle of N x M bermeters. Let us consider an N x M grid of 1 x 1 squares within this rectangle. Peter can move within the lake according to the following:





Input
The first line of the input contains two integers N and M (1 ≤ N, M≤ 500) separated by one space. Each of the next N lines contains M digits each — the description of the lake. The digit is the number of the flow velocity vector in the corresponding cell, according to the statement. The last two lines contain two integers each, the first corresponds to initial coordinates of Peter, the second is for the boat.

Output
Output the minimal time in minutes required for Peter to save himself, rounded up to two digits after decimal point. If Peter is not able to save himself, output "
SOS
".

Example(s)
sample input
sample output
4 6
222222
444444
444444
111111
5 3
6 2
2.00

sample input
sample output
3 2
00
32
11
1 2
2 3
0.67

sample input
sample output
3 5
32240
33442
31140
2 2
5 2
SOS




Online Contester Team © 2002 - 2010. All rights reserved.