import java.io.*; import java.util.*; public class Main_yukicoder424 { private static Scanner sc; private static Printer pr; private static void solve() { int[] dx = {1, -1, 0, 0}; int[] dy = {0, 0, 1, -1}; int[] dx2 = {2, -2, 0, 0}; int[] dy2 = {0, 0, 2, -2}; int h = sc.nextInt(); int w = sc.nextInt(); int sy = sc.nextInt() - 1; int sx = sc.nextInt() - 1; int gy = sc.nextInt() - 1; int gx = sc.nextInt() - 1; char[][] b = new char[h][]; for (int i = 0; i < h; i++) { b[i] = sc.next().toCharArray(); } Queue qx = new ArrayDeque<>(); Queue qy = new ArrayDeque<>(); qx.add(sx); qy.add(sy); boolean[][] used = new boolean[h][w]; used[sy][sx] = true; while (!qx.isEmpty()) { int x = qx.remove(); int y = qy.remove(); if (x == gx && y == gy) { pr.println("YES"); return; } for (int i = 0, size = dx.length; i < size; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx < 0 || nx >= w || ny < 0 || ny >= h) { continue; } if (used[ny][nx] == true) { continue; } if (Math.abs(b[ny][nx] - b[y][x]) <= 1) { qx.add(nx); qy.add(ny); used[ny][nx] = true; } } for (int i = 0, size = dx.length; i < size; i++) { int nx = x + dx[i]; int ny = y + dy[i]; int nx2 = x + dx2[i]; int ny2 = y + dy2[i]; if (nx2 < 0 || nx2 >= w || ny2 < 0 || ny2 >= h) { continue; } if (used[ny2][nx2] == true) { continue; } if (b[ny2][nx2] == b[y][x] && b[ny][nx] < b[y][x]) { qx.add(nx2); qy.add(ny2); used[ny2][nx2] = true; } } } pr.println("NO"); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }