#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
char M[maxn][maxn];
int n, m;
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
int bx, by;
int ex, ey;
int main() {
  int i, j, k;
  queue<pair<int, int> > Q;
  int x, y;
  int xx, yy;
  bool flag;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; ++i) scanf("%s", M[i] + 1);
  scanf("%d %d %d %d", &bx, &by, &ex, &ey);
  flag = false;
  Q.push(make_pair(bx, by));
  while (!Q.empty()) {
    x = Q.front().first;
    y = Q.front().second;
    Q.pop();
    for (i = 0; i < 4; ++i) {
      xx = x + dir[i][0];
      yy = y + dir[i][1];
      if (xx <= 0 || xx > n || yy <= 0 || yy > m) continue;
      if (M[xx][yy] == 'X') {
        if (xx == ex && yy == ey) {
          flag = true;
          goto _output;
        }
      } else {
        M[xx][yy] = 'X';
        Q.push(make_pair(xx, yy));
      }
    }
  }
_output:
  if (flag)
    puts("YES");
  else
    puts("NO");
  return 0;
}
