#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int r1, c1, r2, c2;
char a[N][N];
int d[N * N], num[N * N];
struct union_find {
  void init(int xx) {
    for (int i = 0; i < xx; i++) d[i] = i, num[i] = 1;
  }
  int finds(int x) { return (x != d[x]) ? (d[x] = finds(d[x])) : x; }
  bool uu(int x, int y) {
    x = finds(x);
    y = finds(y);
    if (x == y) return 0;
    if (num[x] > num[y]) {
      num[x] += num[y];
      d[y] = x;
    } else {
      num[y] += num[x];
      d[x] = y;
    }
    return 1;
  }
} U;
int n, m;
int get(int x, int y) { return x * m + y; }
bool out(int x, int y) {
  if (x < 0 || y < 0 || x >= n || y >= m)
    return true;
  else
    return false;
}
bool valid(int x, int y) {
  if (out(x, y)) return false;
  if (x == r1 && y == c1) return true;
  if (x == r2 && y == c2) return true;
  return a[x][y] == '.';
}
int r[] = {1, -1, 0, 0};
int c[] = {0, 0, 1, -1};
int main() {
  int i, j, k;
  cin >> n >> m;
  U.init(n * m);
  for (int i = 0; i < n; i++) scanf("%s", a[i]);
  cin >> r1 >> c1 >> r2 >> c2;
  r1--, c1--, r2--, c2--;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (valid(i, j)) {
        for (int k = 0; k < 4; k++) {
          int x = i + r[k];
          int y = j + c[k];
          if (valid(x, y)) {
            U.uu(get(i, j), get(x, y));
          }
        }
      }
    }
  if (r1 == r2 && c1 == c2) {
    for (int i = 0; i < 4; i++) {
      int x = r1 + r[i];
      int y = c1 + c[i];
      if (out(x, y)) continue;
      if (a[x][y] == '.') {
        cout << "YES";
        return 0;
      }
    }
    cout << "NO";
    return 0;
  }
  if (U.finds(get(r1, c1)) != U.finds(get(r2, c2))) {
    cout << "NO";
  } else {
    if (a[r2][c2] == 'X')
      cout << "YES";
    else {
      int cnt = 0;
      for (int i = 0; i < 4; i++) {
        int x = r2 + r[i];
        int y = c2 + c[i];
        if (valid(x, y)) cnt++;
      }
      if (cnt >= 2)
        cout << "YES";
      else
        cout << "NO";
    }
  }
  return 0;
}
