#include <bits/stdc++.h>
using namespace std;
char ma[550][550];
int vis[550][550];
int n, m, flag;
int r1, c1, r2, c2;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
void dfs(int r, int c) {
  if (flag) return;
  if (vis[r][c]) {
    if (r == r2 && c == c2) {
      flag = 1;
      return;
    } else
      return;
  } else {
    vis[r][c] = 1;
    for (int i = 0; i < 4; i++) {
      int rr = dx[i] + r;
      int cc = dy[i] + c;
      if (rr <= 0 || rr > n || cc <= 0 || cc > m) continue;
      dfs(rr, cc);
      if (flag) return;
    }
  }
}
int main() {
  while (scanf("%d %d", &n, &m) == 2) {
    memset(vis, 0, sizeof(vis));
    memset(ma, 0, sizeof(ma));
    getchar();
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        scanf("%c", &ma[i][j]);
        if (ma[i][j] == 'X') vis[i][j] = 1;
      }
      getchar();
    }
    scanf("%d %d", &r1, &c1);
    scanf("%d %d", &r2, &c2);
    flag = 0;
    vis[r1][c1] = 0;
    dfs(r1, c1);
    if (flag)
      puts("YES");
    else
      puts("NO");
  }
}
