#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  return out << "(" << a.first << "," << a.second << ")";
}
template <class A>
ostream &operator<<(ostream &out, const vector<A> &a) {
  for (const A &it : a) out << it << " ";
  return out;
}
template <class A, class B>
istream &operator>>(istream &in, pair<A, B> &a) {
  return in >> a.first >> a.second;
}
template <class A>
istream &operator>>(istream &in, vector<A> &a) {
  for (A &i : a) in >> i;
  return in;
}
ifstream cinn("input.txt");
ofstream coutt("output.txt");
long long n, m;
long long a, b, c, d;
char v[505][505];
bool vis[505][505];
long long dx[] = {0, 1, -1, 0};
long long dy[] = {1, 0, 0, -1};
void dfs(long long i, long long j) {
  if (i > n || i < 1 || j > m || j < 1) return;
  if (vis[i][j]) return;
  if (i == c && j == d) {
    if (v[i][j] == 'X') {
      cout << "YES";
      exit(0);
    }
    long long dots = 0;
    bool parr = 0;
    for (long long k = 0; k < 4; k++) {
      long long ii = i + dx[k];
      long long jj = j + dy[k];
      if (ii < 1 || ii > n || jj < 1 || jj > m) continue;
      if (v[ii][jj] == 'X') {
        parr |= (ii == a && jj == b);
        continue;
      }
      dots++;
    }
    if (dots >= 2 || (parr && dots)) {
      cout << "YES";
      exit(0);
    }
    cout << "NO";
    exit(0);
  }
  if (v[i][j] == 'X') return;
  vis[i][j] = 1;
  for (long long k = 0; k < 4; k++) {
    long long ii = i + dx[k];
    long long jj = j + dy[k];
    dfs(ii, jj);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) cin >> v[i][j];
  cin >> a >> b >> c >> d;
  for (long long k = 0; k < 4; k++) {
    long long ii = a + dx[k];
    long long jj = b + dy[k];
    dfs(ii, jj);
  }
  cout << "NO";
}
