#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
string s[55];
int b1[4] = { 0,0,1,-1 };
int b2[4] = { 1,-1,0,0 };
int b3[4] = { 0,0,2,-2 };
int b4[4] = { 2,-2,0,0 };
bool b[55][55] = { false };
int main() {
	int h, w;
	cin >> h >> w;
	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	sx--; sy--; gx--; gy--;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	queue<pair<int, int>> que;
	que.push(make_pair(sx, sy));
	b[sx][sy] = true;
	while (!que.empty()) {
		int x = que.front().first;
		int y = que.front().second;
		if (x == gx && y == gy) {
			cout << "YES" << endl;
			return 0;
		}
		for (int i = 0; i < 4; i++) {
			if (x + b1[i] < 0 || x + b1[i] >= h || y + b2[i] < 0 || y + b2[i] >= w) {
				continue;
			}
			if (abs(int(s[x][y] - s[x + b1[i]][y + b2[i]])) <= 1) {
				if (!b[x + b1[i]][y + b2[i]]) {
					b[x + b1[i]][y + b2[i]] = true;
					que.push(make_pair(x + b1[i], y + b2[i]));
				}
			}
		}
		for (int j = 0; j < 4; j++) {
			if(x + b3[j] < 0 || x + b3[j] >= h || y + b4[j] < 0 || y + b4[j] >= w) {
				continue;
			}
			if(s[x][y] == s[x + b3[j]][y + b4[j]]) {
				if(s[x][y] > s[x + b1[j]][y + b2[j]]) {
				   if(!b[x + b3[j]][y + b4[j]]) {
						b[x + b3[j]][y + b4[j]] = true;
						que.push(make_pair(x + b3[j], y + b4[j]));
					}
				}
			}
		}
		if (x == gx && y == gy) {
			cout << "YES" << endl;
			return 0;
		}
		que.pop();
	}
	cout << "NO" << endl;
	return 0;
}