#include <bits/stdc++.h>
using namespace std;
char G[550][550];
int a[550][550], n, m;
int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
struct node {
  int x, y, step;
} Start, End;
int BFS() {
  int i;
  node p, q;
  queue<node> Q;
  Q.push(Start);
  while (Q.size()) {
    p = Q.front(), Q.pop();
    for (i = 0; i < 4; i++) {
      q.x = p.x + dir[i][0];
      q.y = p.y + dir[i][1];
      if (q.x == End.x && q.y == End.y && a[q.x][q.y] == 1) return 1;
      if (q.x >= 0 && q.x < n && q.y >= 0 && q.y < m && a[q.x][q.y] == 2) {
        a[q.x][q.y]--;
        Q.push(q);
      }
    }
  }
  return 0;
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  memset(G, 0, sizeof(G));
  memset(a, 0, sizeof(a));
  for (i = 0; i < n; i++) {
    scanf("%s", G[i]);
    for (j = 0; j < m; j++) {
      if (G[i][j] == 'X') a[i][j] = 1;
      if (G[i][j] == '.') a[i][j] = 2;
    }
  }
  scanf("%d%d", &Start.x, &Start.y);
  scanf("%d%d", &End.x, &End.y);
  Start.x--, Start.y--;
  End.x--, End.y--;
  Start.step = 0;
  int ans = BFS();
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
