#include <bits/stdc++.h>
using namespace std;
const int mx = 510;
char s[mx][mx];
int n, m;
struct node {
  int x, y;
  node(int x = 0, int y = 0) : x(x), y(y) {}
};
bool d[mx][mx];
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, -1, 0, 1};
node walk(const node& u, int i) { return node(u.x + dr[i], u.y + dc[i]); }
bool inside(const node& v) {
  return v.x > 0 && v.x <= n && v.y > 0 && v.y <= m;
}
bool bfs(node st, node e) {
  queue<node> q;
  memset(d, 0, sizeof d);
  d[st.x][st.y] = 1;
  q.push(st);
  while (!q.empty()) {
    node u = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      node v = walk(u, i);
      if (v.x == e.x && v.y == e.y) return 1;
      if (!inside(v)) continue;
      if (s[v.x][v.y] == 'X') continue;
      if (d[v.x][v.y]) continue;
      d[v.x][v.y] = 1;
      q.push(v);
    }
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  int r, c, r1, c1;
  scanf("%d%d%d%d", &r, &c, &r1, &c1);
  if (!bfs(node(r, c), node(r1, c1))) {
    printf("NO\n");
    return 0;
  }
  if (s[r1][c1] == 'X') {
    printf("YES\n");
    return 0;
  }
  int num = 0;
  for (int i = 0; i < 4; i++) {
    node v = walk(node(r1, c1), i);
    if (!inside(v)) continue;
    if (d[v.x][v.y]) {
      num++;
      continue;
    }
    if (s[v.x][v.y] == 'X') continue;
    num++;
  }
  printf("%s\n", num > 1 ? "YES" : "NO");
  return 0;
}
