#include <bits/stdc++.h>
using namespace std;
const int M = 505;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
int n, m;
char str[M][M];
int stx, sty, gtx, gty;
bool judge(int x, int y) {
  return x > 0 && x <= n && y > 0 && y <= m && str[x][y] == '.';
}
bool vis[M][M];
void bfs() {
  queue<int> q;
  q.push(stx), q.push(sty);
  vis[stx][sty] = true;
  if (stx == gtx && sty == gty) puts("YES"), exit(0);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    int y = q.front();
    q.pop();
    for (int d = 0; d < 4; d++) {
      int nx = dx[d] + x, ny = dy[d] + y;
      if (!judge(nx, ny) || vis[nx][ny]) continue;
      if (nx == gtx && ny == gty) puts("YES"), exit(0);
      vis[nx][ny] = true;
      q.push(nx), q.push(ny);
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", str[i] + 1);
  scanf("%d %d %d %d", &stx, &sty, &gtx, &gty);
  int cnt = 0;
  for (int d = 0; d < 4; d++) {
    int x = gtx + dx[d], y = gty + dy[d];
    if (judge(x, y) || x == stx && y == sty) ++cnt;
  }
  if (str[gtx][gty] == 'X' && cnt || str[gtx][gty] == '.' && cnt >= 2) {
    str[gtx][gty] = '.';
    bfs();
  }
  puts("NO");
  return 0;
}
