#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
vector<int> ans;
int d[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
int n, m;
char s[N][N];
int f(int x, int y) {
  int cnt = 0;
  for (int k = 0; k < 4; k++) {
    int xx = x + d[k][0], yy = y + d[k][1];
    if (xx < 1 || xx > n || yy < 1 || yy > m) continue;
    if (s[xx][yy] == '.') cnt++;
  }
  return cnt;
}
bool vis[N][N];
int g(int x, int y) {
  int cnt = 0;
  for (int k = 0; k < 4; k++) {
    int xx = x + d[k][0], yy = y + d[k][1];
    if (xx < 1 || xx > n || yy < 1 || yy > m) continue;
    cnt += vis[xx][yy];
  }
  return cnt;
}
int main() {
  int r1, c1, r2, c2;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
  if (r1 == r2 && c1 == c2)
    printf("%s", f(r1, c1) ? "YES" : "NO");
  else {
    queue<pair<int, int>> q;
    q.push(make_pair(r1, c1));
    vis[r1][c1] = 1;
    while (!q.empty()) {
      int x = q.front().first, y = q.front().second;
      q.pop();
      for (int k = 0; k < 4; k++) {
        int xx = x + d[k][0], yy = y + d[k][1];
        if (xx < 1 || xx > n || yy < 1 || yy > m || vis[xx][yy] ||
            s[xx][yy] == 'X')
          continue;
        if (s[xx][yy] == '.') {
          q.push(make_pair(xx, yy));
          vis[xx][yy] = 1;
        }
      }
    }
    if ((vis[r2][c2] && g(r2, c2) > 1) || (s[r2][c2] == 'X' && g(r2, c2)))
      printf("YES");
    else
      printf("NO");
  }
  return 0;
}
