#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<string> a;
bool v[505][505];
long long found = false;
long long q, w;
bool allowed(long long x, long long y) {
  if (x >= 0 && x < n && y >= 0 && y < m && !v[x][y] && a[x][y] != 'X')
    return true;
  return false;
}
vector<pair<long long, long long>> d = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
void bfs(long long x, long long y) {
  v[x][y] = true;
  if (x == q && y == w) {
    found = true;
    return;
  }
  for (auto u : d) {
    long long nx = x + u.first;
    long long ny = y + u.second;
    if (allowed(nx, ny)) bfs(nx, ny);
  }
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    a.push_back(s);
  }
  long long x, y;
  cin >> x >> y;
  cin >> q >> w;
  x--, y--, q--, w--;
  if (a[q][w] == 'X') {
    a[q][w] = '.';
    long long cnt = 0;
    if (q == x && w == y) {
      for (auto u : d) {
        long long nx = q + u.first;
        long long ny = w + u.second;
        if (allowed(nx, ny)) cnt++;
      }
    } else
      bfs(x, y);
    if (found || cnt)
      cout << "YES\n";
    else
      cout << "NO\n";
  } else {
    long long cnt = 0;
    for (auto u : d) {
      long long nx = q + u.first;
      long long ny = w + u.second;
      if (allowed(nx, ny) || (nx == x && ny == y)) cnt++;
    }
    bfs(x, y);
    if (found && cnt >= 2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) solve();
}
