Problem: A maze is composed of a grid of H \times W squares - H vertical, W horizontal.

The square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is `#` and a road if S_{ij} is `.`.

There is a magician in (C_h,C_w). He can do the following two kinds of moves:

* Move A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.
* Move B: Use magic to warp himself to a road square in the 5\times 5 area centered at the square he is currently in.



In either case, he cannot go out of the maze.

At least how many times does he need to use the magic to reach (D_h, D_w)?

Constraints

* 1 \leq H,W \leq 10^3
* 1 \leq C_h,D_h \leq H
* 1 \leq C_w,D_w \leq W
* S_{ij} is `#` or `.`.
* S_{C_h C_w} and S_{D_h D_w} are `.`.
* (C_h,C_w) \neq (D_h,D_w)

Input

Input is given from Standard Input in the following format:


H W
C_h C_w
D_h D_w
S_{11}\ldots S_{1W}
\vdots
S_{H1}\ldots S_{HW}


Output

Print the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print `-1` instead.

Examples

Input

4 4
1 1
4 4
..#.
..#.
.#..
.#..


Output

1


Input

4 4
1 4
4 1
.##.


.##.


Output

-1


Input

4 4
2 2
3 3
....
....
....
....


Output

0


Input

4 5
1 2
2 5
.###
.
..##
..##


Output

2

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static int Y,X;
    static char [][]grid;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        Y = fs.nextInt();
        X = fs.nextInt();
        int sy = fs.nextInt(), sx = fs.nextInt(), ey = fs.nextInt(), ex = fs.nextInt();
        sy--;
        sx--;
        ey--;
        ex--;
        grid = new char[Y][X];
        for (int y = 0; y < Y; y++) {
            char [] row = fs.next().toCharArray();
            for (int x = 0; x < X; x++) {
                grid[y][x] = row[x];
            }
        }
/*        Deque<Integer> Qx = new ArrayDeque<Integer>(), Qy = new ArrayDeque<Integer>();
        Qx.offer(sx);
        Qy.offer(sy);*/
        Deque<int[]> Q = new ArrayDeque<>();
        Q.offer(new int[]{sx,sy});
        int [] dx = {1,-1,0,0};
        int [] dy = {0,0,-1,1};
        int [][] dist = new int [Y][X];
        for (int[] row : dist) {
            Arrays.fill(row,Integer.MAX_VALUE);
        }
        dist[sy][sx] = 0;
        while (!Q.isEmpty()) {
            int [] cur = Q.poll();
            int cx = cur[0];
            int cy = cur[1];
            for (int i = 0; i < 4; i++) {
                int nx = cx + dx[i], ny = cy + dy[i];
                if (legal(ny, nx) && dist[ny][nx] > dist[cy][cx]) {
                    dist[ny][nx] = dist[cy][cx];
/*                    Qx.offerFirst(nx);
                    Qy.offerFirst(ny);*/
                    Q.offerFirst(new int[]{nx,ny});
                }
            }
            for (int x = -2; x <= 2; x++) {
                for (int y = -2; y <= 2; y++) {
                    int nx = cx + x, ny = cy + y;
                    if (legal(ny, nx) && dist[ny][nx] > dist[cy][cx] + 1) {
                        dist[ny][nx] = dist[cy][cx] + 1;
                        /*Qx.offer(nx);
                        Qy.offer(ny);*/
                        Q.offer(new int[]{nx,ny});
                    }
                }
            }
        }
        if (dist[ey][ex] != Integer.MAX_VALUE) System.out.println(dist[ey][ex]);
        else System.out.println(-1);


    }
    static boolean  legal(int y, int x) {
        if (x < 0 || x >= X || y < 0 || y >= Y || grid[y][x] == '#') return false;
        return true;
    }

    static void prln ( char[] s){
        __out.println(new String(s));
    }
    static final Random random = new Random();

    static void ruffleSort(int[] a) {
        int n = a.length;//shuffle, then sort
        for (int i = 0; i < n; i++) {
            int oi = random.nextInt(n), temp = a[oi];
            a[oi] = a[i];
            a[i] = temp;
        }
        Arrays.sort(a);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }


}