#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > vv, used;
vector<vector<pair<int, int> > > parent;
vector<pair<int, int> > cur;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int n, m, f_x, f_y;
;
void bfs(pair<int, int> v) {
  queue<pair<int, int> > q;
  q.push(v);
  used[v.first][v.second] = 1;
  while (q.size() > 0) {
    auto v = q.front();
    q.pop();
    int x = v.first, y = v.second;
    for (int i = 0; i < 4; i++) {
      if (x + dx[i] == f_x && y + dy[i] == f_y && vv[f_x][f_y] == 0) {
        cout << "YES";
        exit(0);
      }
      if (x + dx[i] > n - 1 || y + dy[i] > m - 1 || x + dx[i] < 0 ||
          y + dy[i] < 0 || vv[x + dx[i]][y + dy[i]] == 0 ||
          used[x + dx[i]][y + dy[i]] == 1)
        continue;
      q.push({x + dx[i], y + dy[i]});
      used[x + dx[i]][y + dy[i]] = 1;
      parent[x + dx[i]][y + dy[i]] = {x, y};
    }
  }
}
void clear(pair<int, int> v) {
  int x = v.first, y = v.second;
  while (parent[x][y].first != -1) {
    vv[x][y]--;
    auto p = parent[x][y];
    x = p.first;
    y = p.second;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      parent[i][j] = {-1, -1};
      used[i][j] = 0;
    }
}
int main() {
  int s_x, s_y;
  cin >> n >> m;
  vv.resize(n, vector<int>(m));
  used.resize(n, vector<int>(m));
  parent.resize(n, vector<pair<int, int> >(m, {-1, -1}));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char x;
      cin >> x;
      vv[i][j] = (x == 'X') ? 0 : 1;
    }
  cin >> s_x >> s_y >> f_x >> f_y;
  s_x--;
  s_y--;
  f_x--;
  f_y--;
  bfs({s_x, s_y});
  if (used[f_x][f_y] == 0) return cout << "NO", 0;
  clear({f_x, f_y});
  bfs({f_x, f_y});
  cout << "NO";
}
