#include <bits/stdc++.h>
using namespace std;
int n, m;
char str[505][505];
int d[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
bool vis[505][505];
int px, py, qx, qy;
pair<int, int> q[1000001], pre[505][505];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  scanf("%d %d", &px, &py);
  scanf("%d %d", &qx, &qy);
  --px, --qx, --py, --qy;
  int h = 0, t = 1;
  q[t] = make_pair(px, py);
  while (h < t) {
    pair<int, int> k = q[++h];
    for (int i = 0; i < 4; i++) {
      int tmpx = k.first + d[i][0];
      int tmpy = k.second + d[i][1];
      if (tmpx < 0 || tmpx >= n || tmpy < 0 || tmpy >= m) continue;
      if (str[tmpx][tmpy] == 'X' && (tmpx != qx || tmpy != qy)) continue;
      if (vis[tmpx][tmpy]) continue;
      q[++t] = make_pair(tmpx, tmpy);
      pre[tmpx][tmpy] = k;
      vis[tmpx][tmpy] = true;
    }
  }
  if (!vis[qx][qy])
    printf("NO\n");
  else {
    if (str[qx][qy] == 'X') {
      printf("YES\n");
      return 0;
    }
    for (int i = qx, j = qy; i != px || j != py;) {
      if (i != qx || j != qy) str[i][j] = 'X';
      pair<int, int> tmp = pre[i][j];
      i = tmp.first, j = tmp.second;
    }
    memset(vis, false, sizeof(vis));
    int h = 0, t = 1;
    q[t] = make_pair(qx, qy);
    while (h < t) {
      pair<int, int> k = q[++h];
      for (int i = 0; i < 4; i++) {
        int tmpx = k.first + d[i][0];
        int tmpy = k.second + d[i][1];
        if (tmpx < 0 || tmpx >= n || tmpy < 0 || tmpy >= m) continue;
        if (str[tmpx][tmpy] == 'X') continue;
        if (vis[tmpx][tmpy]) continue;
        q[++t] = make_pair(tmpx, tmpy);
        pre[tmpx][tmpy] = k;
        vis[tmpx][tmpy] = true;
      }
    }
    if (vis[qx][qy])
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
