#include <bits/stdc++.h>
using namespace std;
long long const MOD = 1000000007;
const int Mx = 1e5;
vector<long long> v[Mx + 10];
long long n, m, p, q, l, w;
pair<long long, long long> E, S;
bool vis[1000][1000];
bool ok, flag;
long long cost[Mx + 1];
char ara[1000][1000];
bool check(long long i, long long j) {
  if (i < 1 || j < 1 || i > n || j > m || (vis[i][j] && flag))
    return false;
  else
    return true;
}
void call(long long i, long long j) {
  if (E.first == i && E.second == j && vis[i][j] && flag) {
    ok = true;
    return;
  }
  if (!check(i, j)) {
    return;
  }
  flag = true;
  vis[i][j] = true;
  call(i + 1, j);
  call(i - 1, j);
  call(i, j + 1);
  call(i, j - 1);
  return;
}
void input() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; ++j) {
      char ch;
      cin >> ch;
      ara[i][j] = ch;
      if (ch == 'X') vis[i][j] = true;
    }
  }
  cin >> S.first >> S.second;
  cin >> E.first >> E.second;
}
int main() {
  input();
  call(S.first, S.second);
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
