#include <bits/stdc++.h>
using namespace std;
int n, m;
bool valid(int x, int y) { return (x < n && x >= 0 && y < m && y >= 0); }
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  a--, b--, c--, d--;
  if (abs(a - c) + abs(b - d) == 1) {
    if (s[c][d] == 'X') {
      cout << "YES" << endl;
      return 0;
    }
    int ct = 0;
    if (valid(c, d + 1) && s[c][d + 1] == '.') ct++;
    if (valid(c + 1, d) && s[c + 1][d] == '.') ct++;
    if (valid(c, d - 1) && s[c][d - 1] == '.') ct++;
    if (valid(c - 1, d) && s[c - 1][d] == '.') ct++;
    if (ct > 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  vector<vector<int> > vis(n, vector<int>(m, 0));
  stack<pair<int, int> > q;
  q.push(make_pair(a, b));
  while (!q.empty()) {
    pair<int, int> top = q.top();
    q.pop();
    int x = top.first;
    int y = top.second;
    vis[x][y] = true;
    if (x == c && y == d) {
      if (a == c && b == d) {
        int ct = 0;
        if (valid(x, y + 1) && s[x][y + 1] == '.') ct++;
        if (valid(x + 1, y) && s[x + 1][y] == '.') ct++;
        if (valid(x, y - 1) && s[x][y - 1] == '.') ct++;
        if (valid(x - 1, y) && s[x - 1][y] == '.') ct++;
        if (ct > 0)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        return 0;
      }
      if (s[x][y] == 'X') {
        cout << "YES" << endl;
        return 0;
      } else {
        int ct = 0;
        if (valid(x, y + 1) && s[x][y + 1] == '.') ct++;
        if (valid(x + 1, y) && s[x + 1][y] == '.') ct++;
        if (valid(x, y - 1) && s[x][y - 1] == '.') ct++;
        if (valid(x - 1, y) && s[x - 1][y] == '.') ct++;
        if (ct > 1)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        return 0;
      }
    }
    if (valid(x, y + 1) && !vis[x][y + 1]) {
      vis[x][y + 1] = true;
      if (s[x][y + 1] == 'X') {
        if (x == c && y + 1 == d) {
          cout << "YES" << endl;
          return 0;
        }
      } else
        q.push(make_pair(x, y + 1));
    }
    if (valid(x + 1, y) && !vis[x + 1][y]) {
      vis[x + 1][y] = true;
      if (s[x + 1][y] == 'X') {
        if (x + 1 == c && y == d) {
          cout << "YES" << endl;
          return 0;
        }
      } else
        q.push(make_pair(x + 1, y));
    }
    if (valid(x, y - 1) && !vis[x][y - 1]) {
      vis[x][y - 1] = true;
      if (s[x][y - 1] == 'X') {
        if (x == c && y - 1 == d) {
          cout << "YES" << endl;
          return 0;
        }
      } else
        q.push(make_pair(x, y - 1));
    }
    if (valid(x - 1, y) && !vis[x - 1][y]) {
      vis[x - 1][y] = true;
      if (s[x - 1][y] == 'X') {
        if (x - 1 == c && y == d) {
          cout << "YES" << endl;
          return 0;
        }
      } else
        q.push(make_pair(x - 1, y));
    }
  }
  cout << "NO" << endl;
  return 0;
}
