#include <bits/stdc++.h>
using namespace std;
string s[501];
bool vis[501][501];
long long int n, m;
void dfs(long long int x, long long int y, bool f = true) {
  if (x < 0 || x >= n || y < 0 || y >= m || (s[x][y] == 'X' && f)) return;
  if (vis[x][y]) return;
  vis[x][y] = true;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  long long int r, c;
  long long int dr, dc;
  cin >> r >> c >> dr >> dc;
  dfs(r - 1, c - 1, false);
  long long int deg = 0;
  dr = dr - 1;
  dc = dc - 1;
  if (s[dr][dc] != 'X' && vis[dr][dc]) {
    deg = (dr + 1 < n && vis[dr + 1][dc]) + (dr - 1 >= 0 && vis[dr - 1][dc]) +
          (dc + 1 < m && vis[dr][dc + 1]) + (dc - 1 >= 0 && vis[dr][dc - 1]);
    if (deg >= 2) {
      cout << "YES" << endl;
      return 0;
    }
  } else {
    deg = (dr + 1 < n && vis[dr + 1][dc]) + (dr - 1 >= 0 && vis[dr - 1][dc]) +
          (dc + 1 < m && vis[dr][dc + 1]) + (dc - 1 >= 0 && vis[dr][dc - 1]);
    if (deg >= 1) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
