We are given a rectangular city map made of n×m unit squares, where 1≤n≤100 and 1≤m≤100. The rows are numbered from 1 to n from top to bottom, and the columns from 1 to m from left to right. Every square is either free or blocked, and traffic is allowed only on free squares.
From a free square you may move to a free square adjacent to it (one that shares a side). You may never immediately turn back, that is, you may not return to the square you have just left (no U-turn). You may also never make a left turn: after each move you may only keep going straight or turn right, relative to your current direction of travel. The very first move out of the start square may point in any of the four directions, because there is no previous direction yet.
The length of a route is the number of squares it passes through, counting both endpoints; a square may be counted more than once if the route visits it more than once.
You are given two different squares A and B. Decide whether it is possible to drive from A to B without any left turn, and if it is, report the minimum possible length of such a route. If A or B is blocked, no route exists.
The first line contains two integers n and m separated by a single space.
Each of the next n lines contains a string of length m made of the digits 0 and 1 that describes one row of the map: 0 marks a free square and 1 marks a blocked square.
The next line contains two integers, the row and the column of square A. The following line contains, in the same format, the row and the column of square B. Squares A and B are different. The input is always well-formed and you do not need to validate it.
Print a single line.
If there is no route from A to B without a left turn, or if A or B is blocked, print the single word NIE (Polish for "no").
Otherwise print one integer: the minimum length of a route from A to B that makes no left turn, that is, the number of squares it passes through, counting both A and B.