#include <bits/stdc++.h>
using namespace std;
int num;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int n, m, xi, yi, xf, yf;
char maze[507][507];
bool vis[507][507];
bool ok(int x, int y) { return x < n && x >= 0 && y >= 0 && y < m; }
void dfs(int x, int y) {
  if (x >= n || y >= m) return;
  vis[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (xx == xf && yy == yf) {
      if (vis[xx][yy]) num++;
    }
    if (!vis[xx][yy] && ok(xx, yy)) {
      dfs(xx, yy);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> maze[i][j];
      if (maze[i][j] == 'X') {
        vis[i][j] = 1;
      }
    }
  cin >> xi >> yi;
  xi--;
  yi--;
  cin >> xf >> yf;
  xf--;
  yf--;
  dfs(xi, yi);
  if (num > 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
