#include <bits/stdc++.h>
using namespace std;
bool vis[502][502], vis2[502][502];
char str[502][502];
int dirx[] = {1, 0, -1, 0};
int diry[] = {0, -1, 0, 1};
int n, m, x2, y2;
bool dfs(int x, int y) {
  vis[x][y] = 1;
  if (x == x2 && y == y2) return 1;
  for (int i = 0; i < 4; i++) {
    int x1 = x + dirx[i];
    int y1 = y + diry[i];
    if (x1 >= 0 && x1 < n && y1 >= 0 && y1 < m && !vis[x1][y1] &&
        ((x1 == x2 && y1 == y2) || (str[x1][y1] != 'X'))) {
      vis[x1][y1] = 1;
      if (dfs(x1, y1)) return 1;
    }
  }
  return 0;
}
int main() {
  int x1, y1;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  x1--, x2--, y1--, y2--;
  if (x1 == x2 && y1 == y2) {
    for (int i = 0; i < 4; i++) {
      int a = x1 + dirx[i];
      int b = y1 + diry[i];
      if (a >= 0 && a < n && b >= 0 && b < m && str[a][b] != 'X') {
        printf("YES\n");
        return 0;
      }
    }
    printf("NO\n");
  } else {
    if (str[x2][y2] == 'X') {
      if (dfs(x1, y1))
        printf("YES\n");
      else
        printf("NO\n");
    } else {
      for (int i = 0; i < 4; i++) {
        int a = x2 + dirx[i];
        int b = y2 + diry[i];
        if (a >= 0 && a < n && b >= 0 && b < m && str[a][b] != 'X') {
          memset(vis, 0, sizeof vis);
          vis[a][b] = 1;
          if (dfs(x1, y1)) {
            printf("YES\n");
            return 0;
          }
        }
      }
      printf("NO\n");
    }
  }
  return 0;
}
