#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3;
int n, m;
char a[maxn][maxn];
int sx, sy;
int ex, ey;
int ans = 0;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
queue<pair<int, int> > q;
int judge(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
int bfs() {
  int nx, ny, x, y;
  q.push({sx, sy});
  while (!q.empty()) {
    pair<int, int> tmp = q.front();
    q.pop();
    x = tmp.first;
    y = tmp.second;
    for (int i = 0; i < 4; i++) {
      nx = x + dx[i];
      ny = y + dy[i];
      if (!judge(nx, ny)) continue;
      if (nx == ex && ny == ey && a[nx][ny] == 'X') return 1;
      if (a[nx][ny] == '.') {
        a[nx][ny] = 'X';
        q.push({nx, ny});
      }
    }
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", a[i]);
  scanf("%d%d", &sx, &sy);
  scanf("%d%d", &ex, &ey);
  sx--, sy--;
  ex--, ey--;
  ans = bfs();
  if (ans)
    puts("YES");
  else
    puts("NO");
  return 0;
}
