#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void FastInputOutput() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void ReadFromFile(string name, string extention) {
  string fullPath = name + "." + extention;
  freopen(fullPath.c_str(), "r", stdin);
}
inline int D() {
  int t;
  scanf("%d", &t);
  return t;
}
inline long long LLD() {
  long long t;
  scanf("%lld", &t);
  return t;
}
inline char C() {
  char c;
  scanf("%c", &c);
  return c;
}
long long power(long long x, long long p, long long m) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int dx[] = {0, 0, -1, +1};
int dy[] = {-1, +1, 0, 0};
const int N = 5e2 + 5;
char a[N][N];
int vst[N][N];
int n, m, r1, c1, r2, c2;
bool isValid(int i, int j) {
  return i >= 0 && j >= 0 && i < n && j < m && !vst[i][j] && a[i][j] != 'X';
}
bool DFS(int r, int c) {
  if (r == r2 && c == c2) return true;
  vst[r][c] = 1;
  bool ret = false;
  for (int i = 0; i < 4; ++i) {
    int nr = r + dx[i];
    int nc = c + dy[i];
    if (isValid(nr, nc)) ret |= DFS(nr, nc);
  }
  return ret;
}
bool solve() {
  n = D(), m = D();
  for (int i = 0; i < n; ++i) scanf("%s", a[i]);
  r1 = D(), c1 = D();
  --c1, --r1;
  r2 = D(), c2 = D();
  --c2, --r2;
  bool isBrocken = a[r2][c2] == 'X';
  a[r1][c1] = a[r2][c2] = '.';
  int cntNotBrocken = 0;
  for (int i = 0; i < 4; ++i) {
    int nr = r2 + dx[i];
    int nc = c2 + dy[i];
    if (isValid(nr, nc)) ++cntNotBrocken;
  }
  if (r1 == r2 && c1 == c2) return cntNotBrocken >= 1;
  bool rechableToTarget = DFS(r1, c1);
  if (!rechableToTarget) return false;
  return isBrocken || cntNotBrocken > 1;
}
int main() { puts(solve() ? "YES" : "NO"); }
