#include <bits/stdc++.h>
using namespace std;
const int maxn = 550;
int n, m, sx, sy, ex, ey, mp[maxn][maxn];
char ch[maxn][maxn];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
struct node {
  int x, y;
};
queue<node> qu;
bool check(int x, int y) {
  if (x >= 0 && x < n && y >= 0 && y < m && mp[x][y] == 2) return true;
  return false;
}
bool bfs() {
  while (!qu.empty()) qu.pop();
  node no, po;
  no.x = sx;
  no.y = sy;
  qu.push(no);
  while (!qu.empty()) {
    no = qu.front();
    qu.pop();
    for (int i = 0; i < 4; i++) {
      int xx = dx[i] + no.x;
      int yy = dy[i] + no.y;
      if (xx == ex && yy == ey && mp[xx][yy] == 1) {
        return true;
      }
      if (check(xx, yy)) {
        po.x = xx;
        po.y = yy;
        mp[xx][yy]--;
        qu.push(po);
      }
    }
  }
  return false;
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  memset(mp, 0, sizeof(mp));
  for (i = 0; i < n; i++) {
    scanf("%s", ch[i]);
    for (j = 0; j < m; j++) {
      if (ch[i][j] == 'X')
        mp[i][j] = 1;
      else
        mp[i][j] = 2;
    }
  }
  scanf("%d%d", &sx, &sy);
  scanf("%d%d", &ex, &ey);
  sx--;
  sy--;
  ex--;
  ey--;
  int ans = bfs();
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
