#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 7, INF = 1e9;
char a[510][510];
int n, m;
int xx, xxx, yyy, yy;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool used[550][550];
int cnt(int x, int y) {
  int r = 0;
  for (int i = 0; i < 4; i++) {
    if (x + dx[i] >= 1 && x + dx[i] <= n && y + dy[i] >= 1 && y + dy[i] <= m) {
      if (a[x + dx[i]][y + dy[i]] == '.') {
        r++;
      }
    }
  }
  return r;
}
void dfs(int x, int y) {
  used[x][y] = true;
  for (int i = 0; i < 4; i++) {
    if (x + dx[i] >= 1 && x + dx[i] <= n && y + dy[i] >= 1 && y + dy[i] <= m) {
      if (!used[x + dx[i]][y + dy[i]] && a[x + dx[i]][y + dy[i]] == '.') {
        dfs(x + dx[i], y + dy[i]);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  cin >> xx >> yy;
  cin >> xxx >> yyy;
  if (xx == xxx && yy == yyy) {
    if (cnt(xx, yy))
      cout << "YES";
    else
      cout << "NO";
    return 0;
  } else {
    if (abs(xx - xxx) + abs(yy - yyy) == 1) {
      if (a[xxx][yyy] == 'X') {
        cout << "YES";
      } else if (cnt(xxx, yyy)) {
        cout << "YES";
      } else {
        cout << "NO";
      }
      return 0;
    } else {
      dfs(xx, yy);
      for (int i = 0; i < 4; i++) {
        if (xxx + dx[i] >= 1 && xxx + dx[i] <= n && yyy + dy[i] >= 1 &&
            yyy + dy[i] <= m) {
          if (used[xxx + dx[i]][yyy + dy[i]]) {
            if (a[xxx][yyy] == 'X') {
              cout << "YES";
              return 0;
            } else if (cnt(xxx, yyy) >= 2) {
              cout << "YES";
              return 0;
            }
          }
        }
      }
    }
  }
  cout << "NO";
  return 0;
}
