#include <bits/stdc++.h>
using namespace std;
int n, k, nr, ind, sol, m, aux = 1, xi, yi, xf, yf;
int viz[503][503];
char a[503][503];
int dx[] = {+1, -1, 0, 0};
int dy[] = {0, 0, +1, -1};
inline void Fill(int x, int y) {
  int k, x1, y1, cnt = 0;
  if (a[x][y] == 'X' && x == xf && y == yf) {
    cout << "YES\n";
    exit(0);
  } else if (a[x][y] == '.') {
    if (x == xf && y == yf) {
      cnt = 0;
      for (k = 0; k < 4; ++k) {
        x1 = x + dx[k];
        y1 = y + dy[k];
        if (a[x1][y1] == '.') cnt++;
      }
      if (cnt > 1) {
        cout << "YES\n";
        exit(0);
      }
    } else {
      if (viz[x][y] == 0) {
        viz[x][y] = 1;
        Fill(x + 1, y);
        Fill(x - 1, y);
        Fill(x, y + 1);
        Fill(x, y - 1);
      }
    }
  }
}
inline void Bordare() {
  int i;
  for (i = 0; i <= n + 1; ++i) viz[i][0] = viz[i][m + 1] = 1;
  for (i = 0; i <= m + 1; ++i) viz[0][i] = viz[n + 1][i] = 1;
}
int main() {
  int i, j;
  cin >> n >> m;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) cin >> a[i][j];
  cin >> xi >> yi;
  cin >> xf >> yf;
  a[xi][yi] = '.';
  Bordare();
  if (xi == xf && yi == yf) {
    if (a[xi + 1][yi] == '.' || a[xi - 1][yi] == '.' || a[xi][yi + 1] == '.' ||
        a[xi][yi - 1] == '.')
      cout << "YES\n";
    else
      cout << "NO\n";
  } else {
    Fill(xi, yi);
    if (sol == 1)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
