#include <bits/stdc++.h>
using namespace std;
string str[503];
int n, m;
int neighbour[4][2] = {{1, 0}, {0, 1}, {0, -1}, {-1, 0}};
queue<pair<int, int> > q;
int mark[502][502];
int func(int r1, int c1, int r2, int c2) {
  int x, y, x1, y1, i, ans;
  pair<int, int> p;
  ans = 0;
  q.push(pair<int, int>(r1, c1));
  while (!q.empty()) {
    p = q.front();
    q.pop();
    x = p.first;
    y = p.second;
    if ((x == r2) && (y == c2)) {
      ans = 1;
      break;
    }
    if (mark[x][y]) continue;
    mark[x][y] = 1;
    for (i = 0; i < 4; i++) {
      x1 = x + neighbour[i][0];
      y1 = y + neighbour[i][1];
      if ((x1 < n) && (x1 >= 0) && (y1 < m) && (y1 >= 0)) {
        if (!mark[x1][y1] && (str[x1][y1] == '.')) {
          q.push(pair<int, int>(x1, y1));
        }
      }
    }
  }
  if (ans == 1) {
    return 1;
  } else
    return 0;
}
int main() {
  int r1, c1, r2, c2, i, val, x, y, key, cnt;
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> str[i];
  }
  cin >> r1 >> c1 >> r2 >> c2;
  r1--;
  c1--;
  r2--;
  c2--;
  if ((r1 == r2) && (c1 == c2)) {
    for (i = 0; i < 4; i++) {
      x = r1 + neighbour[i][0];
      y = c1 + neighbour[i][1];
      if ((x < n) && (x >= 0) && (y < m) && (y >= 0)) {
        if (str[x][y] == '.') {
          cout << "YES\n";
          return 0;
        }
      }
    }
    cout << "NO\n";
    return 0;
  }
  key = val = 0;
  if (str[r2][c2] == 'X') {
    str[r2][c2] = '.';
    key = 1;
  }
  str[r1][c1] = 'X';
  val = func(r1, c1, r2, c2);
  if (val == 0) {
    cout << "NO\n";
    return 0;
  } else {
    if (key == 1) {
      cout << "YES" << endl;
      return 0;
    } else {
      cnt = 0;
      for (i = 0; i < 4; i++) {
        x = r2 + neighbour[i][0];
        y = c2 + neighbour[i][1];
        if ((x < n) && (x >= 0) && (y < m) && (y >= 0)) {
          if ((str[x][y] == '.') || ((x == r1) && (y == c1))) {
            cnt++;
          }
        }
      }
      if (cnt > 1) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
    return 0;
  }
  return 0;
}
