#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
long long n, m, f, g, F, G;
char a[505][505];
bool flag;
void dfs(long long x, long long y) {
  if (x < 0 || y < 0 || x >= n || y >= m) return;
  if (a[x][y] == 'X' && x + 1 == F && y + 1 == G)
    flag = true;
  else if (a[x][y] == 'X') {
    return;
  }
  a[x][y] = 'X';
  for (long long i = 0; i < 4; ++i) {
    dfs(x + dx[i], y + dy[i]);
  }
}
int main() {
  cin >> n >> m;
  flag = false;
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < m; ++j) cin >> a[i][j];
  cin >> f >> g >> F >> G;
  a[f - 1][g - 1] = '.';
  dfs(f - 1, g - 1);
  if (flag)
    cout << "YES";
  else
    cout << "NO";
}
