#include <bits/stdc++.h>
using namespace std;
char graph[600][600];
int rows, cols;
int startR, startC, endR, endC;
int ground[600][600];
bool vis[600][600];
int dr[4] = {1, -1, 0, 0};
int dc[4] = {0, 0, -1, 1};
bool valid(int a, int b) { return a >= 0 && a < rows && b >= 0 && b < cols; }
bool passedDFS;
void dfs(int i, int j) {
  if (passedDFS) return;
  vis[i][j] = 1;
  ground[i][j] += 1;
  if (ground[i][j] >= 2 && !(i == startR && j == startC)) return;
  for (int x = 0; x < 4; x++) {
    int a = i + dr[x];
    int b = j + dc[x];
    if (valid(a, b)) {
      if (a == endR && b == endC) {
        ground[a][b] += 1;
        passedDFS = 1;
        return;
      }
      if (!vis[a][b]) {
        dfs(a, b);
      }
    }
  }
}
int main() {
  scanf("%d %d", &rows, &cols);
  gets(graph[0]);
  for (int i = 0; i < rows; i++) {
    gets(graph[i]);
    for (int j = 0; j < cols; j++) {
      if (graph[i][j] == 'X') ground[i][j] = 1;
    }
  }
  cin >> startR >> startC >> endR >> endC;
  startR--;
  startC--;
  endC--;
  endR--;
  dfs(startR, startC);
  if (passedDFS) {
    if (ground[endR][endC] >= 2) {
      printf("YES\n");
      return 0;
    }
    int count = 0;
    for (int i = 0; i < 4; i++) {
      int a = endR + dr[i];
      int b = endC + dc[i];
      if (valid(a, b) && !ground[a][b]) {
        count++;
      }
    }
    if ((ground[endR][endC] == 1 && count >= 1) || (count >= 2)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  } else {
    printf("NO\n");
  }
}
