#include <bits/stdc++.h>
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
using namespace std;
struct Point {
  int x, y;
};
int M, N;
Point s, f;
bool vis[500][500];
char T[500][500];
bool inside(int x, int y) { return x >= 0 && x < M && y >= 0 && y < N; }
bool BFS(Point s, Point f) {
  queue<Point> q;
  q.push(s);
  vis[s.x][s.y] = true;
  while (!q.empty()) {
    s = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int x = s.x + dx[i];
      int y = s.y + dy[i];
      if (inside(x, y)) {
        if (x == f.x && y == f.y && vis[x][y]) {
          return true;
        }
        if (!vis[x][y] && T[x][y] == '.') {
          vis[x][y] = true;
          q.push((Point){x, y});
        }
      }
    }
  }
  return false;
}
void process() {
  cin >> M >> N;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      cin >> T[i][j];
      if (T[i][j] == 'X') {
        vis[i][j] = true;
      } else {
        vis[i][j] = false;
      }
    }
  }
  cin >> s.x >> s.y >> f.x >> f.y;
  s.x -= 1, s.y -= 1, f.x -= 1, f.y -= 1;
  if (BFS(s, f)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
int main() {
  ios::sync_with_stdio(false);
  process();
  return 0;
}
