#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

const int dx[4] = {1, 0, -1,  0};
const int dy[4] = {0, 1,  0, -1,};

int h, w;

bool inside(int x, int y) {
	return (0 <= x && x < w && 0 <= y && y < h);
}

int main() {
	int sx, sy, gx, gy;
	cin >> h >> w >> sy >> sx >> gy >> gx;
	sx--;
	sy--;
	gx--;
	gy--;

	vector<string> b(h);
	for (int i = 0; i < h; i++) {
		cin >> b[i];
	}

	vector<vector<bool>> went(h, vector<bool>(w, false));
	queue<pair<int, int>> que;

	bool possible = false;
	if (sx == gx && sy == gy) {
		possible = true;
	}

	que.push(make_pair(sx, sy));

	while (!possible && !que.empty()) {
		auto p = que.front();
		que.pop();
		int x = p.first;
		int y = p.second;
		for (int i = 0; i < 4; i++) {
			int nx1 = x + dx[i];
			int ny1 = y + dy[i];
			int nx2 = x + dx[i] * 2;
			int ny2 = y + dy[i] * 2;

			if (inside(nx1, ny1) &&
			    !went[ny1][nx1] &&
			    abs(b[ny1][nx1] - b[y][x]) <= 1)
			{
				went[ny1][nx1] = true;
				que.push(make_pair(nx1, ny1));
				if (nx1 == gx && ny1 == gy) {
					possible = true;
					break;
				}
			}
			if (inside(nx2, ny2) &&
			    !went[ny2][nx2] &&
			    b[ny1][nx1] < b[y][x] &&
			    b[ny2][nx2] == b[y][x])
			{
				went[ny2][nx2] = true;
				que.push(make_pair(nx2, ny2));
				if (nx2 == gx && ny2 == gy) {
					possible = true;
					break;
				}
			}
		}
	}

	cout << (possible ? "YES" : "NO") << endl;
	return 0;
}