#include <bits/stdc++.h>
using namespace std;
struct node {
  char a;
  int r;
  int c;
};
int cnt = 0;
int visited[501][501];
char arr[501][501];
int flag = 0;
void fnc(node path[], int r, int c, int xf, int yf, node temp) {
  visited[temp.r][temp.c] = 1;
  int arr_r[] = {0, 1, 0, -1};
  int arr_c[] = {-1, 0, 1, 0};
  for (int i = 0; i < 4; i++) {
    int rr = temp.r + arr_r[i];
    int cc = temp.c + arr_c[i];
    if (rr >= r || rr < 0)
      continue;
    else if (cc < 0 || cc >= c)
      continue;
    else if (rr == xf && cc == yf) {
      if (arr[rr][cc] == 'X') {
        flag = 1;
        return;
      }
      int top = 0;
      int right = 0;
      int left = 0;
      int down = 0;
      if (rr - 1 >= 0 && rr - 1 < r) {
        top = (visited[rr - 1][cc] != 1) && (arr[rr - 1][cc] == '.');
      }
      if (cc + 1 >= 0 && cc + 1 < c) {
        right = (visited[rr][cc + 1] != 1) && (arr[rr][cc + 1] == '.');
      }
      if (cc - 1 >= 0 && cc - 1 < c) {
        left = (visited[rr][cc - 1] != 1) && (arr[rr][cc - 1] == '.');
      }
      if (rr + 1 >= 0 && rr + 1 < r) {
        down = (visited[rr + 1][cc] != 1) && (arr[rr + 1][cc] == '.');
      }
      if (top || right || left || down) {
        flag = 1;
        return;
      }
    } else if (arr[rr][cc] == 'X')
      continue;
    else if (visited[rr][cc] == 1)
      continue;
    else {
      node t;
      t.a = arr[rr][cc];
      t.r = rr;
      t.c = cc;
      visited[rr][cc] = -1;
      path[cnt++] = t;
    }
  }
}
void fnc1(node path[], int r, int c, int xf, int yf) {
  while (cnt != 0 && flag == 0) {
    node t;
    cnt--;
    t = path[cnt];
    fnc(path, r, c, xf, yf, t);
  }
}
int main() {
  int r, c;
  cin >> r >> c;
  struct node path[250000];
  for (int i = 0; i < r; i++) {
    cin >> arr[i];
  }
  int xs, ys, xf, yf;
  cin >> xs >> ys;
  cin >> xf >> yf;
  xs--;
  ys--;
  xf--;
  yf--;
  path[0].a = '.';
  path[0].r = xs;
  path[0].c = ys;
  visited[xs][ys] = -1;
  cnt = 1;
  fnc1(path, r, c, xf, yf);
  if (flag == 1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
