#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MAX = 500 + 47;
string A[MAX];
int n, m, x2, y2;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool canEnd;
bool inside(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }
void dfs(int x, int y) {
  if (!inside(x, y)) return;
  if (x == x2 && y == y2 && A[x][y] == 'X') {
    canEnd = true;
    return;
  }
  if (A[x][y] == 'X') return;
  A[x][y] = 'X';
  for (int k = (0); k < (4); k++) {
    dfs(x + dx[k], y + dy[k]);
  }
}
int main() {
  int x1, y1;
  cin >> n >> m;
  for (int i = (0); i < (n); i++) cin >> A[i];
  cin >> x1 >> y1 >> x2 >> y2;
  x1--;
  y1--;
  x2--;
  y2--;
  A[x1][y1] = '.';
  dfs(x1, y1);
  if (canEnd) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}
