#include <stdio.h>
#include <stdlib.h>
#include <string.h>



int has_path(char maze[20][20], int rows, int cols, int sr, int sc, int er, int ec) {
    // TODO: implement this function
    (void) maze;
    (void) rows;
    (void) cols;
    (void) sr;
    (void) sc;
    (void) er;
    (void) ec;
    return 0;
}


int main(void) {
    int rows, cols;
    if (scanf("%d %d", &rows, &cols) != 2) { return 0; }
    char maze[20][20];
    for (int r = 0; r < rows; r++) { scanf("%19s", maze[r]); }
    int sr, sc, er, ec;
    if (scanf("%d %d %d %d", &sr, &sc, &er, &ec) != 4) { return 0; }
    printf("%d\n", has_path(maze, rows, cols, sr, sc, er, ec));
    return 0;
}
