#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500, MAXM = 500;
const int DIRX[4] = {-1, 0, 1, 0};
const int DIRY[4] = {0, 1, 0, -1};
int n, m, r1, c1, r2, c2, used[MAXN + 9][MAXM + 9];
char a[MAXN + 9][MAXM + 9];
void Dfs(int x, int y) {
  used[x][y] = 1;
  for (int dir = 0; dir < 4; dir++) {
    int xx = x + DIRX[dir], yy = y + DIRY[dir];
    if (a[xx][yy] == '.' && !used[xx][yy]) {
      Dfs(xx, yy);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  cin >> r1 >> c1 >> r2 >> c2;
  Dfs(r1, c1);
  int cnt = 0;
  for (int dir = 0; dir < 4; dir++) {
    int rr = r2 + DIRX[dir], cc = c2 + DIRY[dir];
    if (used[rr][cc]) {
      cnt++;
    }
  }
  if (a[r2][c2] == 'X' && cnt >= 1 || a[r2][c2] == '.' && cnt >= 2) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
