#include <bits/stdc++.h>
using namespace std;
char ma[550][550];
int stx, sty, edx, edy;
struct Node {
  int x, y, step;
};
int vis[550][550];
queue<Node> que;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int n, m;
bool bfs() {
  Node start;
  start.x = stx, start.y = sty, start.step = 0;
  vis[stx][sty] = 1;
  que.push(start);
  while (!que.empty()) {
    Node now = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int xx = now.x + dx[i];
      int yy = now.y + dy[i];
      if (xx <= 0 || xx > n || yy <= 0 || yy > m) continue;
      if (vis[xx][yy]) {
        if (xx == edx && yy == edy)
          return 1;
        else
          continue;
      }
      if (ma[xx][yy] == 'X') {
        if (xx == edx && yy == edy)
          return 1;
        else
          continue;
      }
      vis[xx][yy] = 1;
      ma[xx][yy] = 'X';
      Node Next;
      Next.step = now.step + 1;
      Next.x = xx;
      Next.y = yy;
      que.push(Next);
    }
  }
  return 0;
}
int main() {
  while (scanf("%d %d", &n, &m) == 2) {
    getchar();
    memset(ma, 0, sizeof(ma));
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) scanf("%c", &ma[i][j]);
      getchar();
    }
    scanf("%d %d", &stx, &sty);
    scanf("%d %d", &edx, &edy);
    int flag = bfs();
    if (flag)
      puts("YES");
    else
      puts("NO");
  }
}
