#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int mov[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
char ar[507][507];
int vis[507][507];
int n, m, curx, cury, goalx, goaly, goal;
bool check;
void dfs(int x, int y) {
  if (vis[x][y] and (x != goalx or y != goaly)) return;
  vis[x][y]++;
  if (vis[goalx][goaly] >= goal) {
    check = true;
    return;
  }
  for (int i = 0; i < 4; i++) {
    int newx = x + mov[i][0];
    int newy = y + mov[i][1];
    if (newx < 1 or newy < 1 or newx > n or newy > m or
        (ar[newx][newy] == 'X' and (newx != goalx or newy != goaly)))
      continue;
    dfs(newx, newy);
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < m + 1; j++) {
      cin >> ar[i][j];
    }
  }
  cin >> curx >> cury >> goalx >> goaly;
  if (n == m and n == 1) {
    cout << "NO"
         << "\n";
    return;
  }
  if (ar[goalx][goaly] == 'X')
    goal = 1;
  else
    goal = 2;
  if (goalx == curx and goaly == cury) goal++;
  dfs(curx, cury);
  if (check)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  for (int i = 0; i < t; i++) solve();
}
