import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); private static int h; private static int w; private static int sx; private static int sy; private static int ex; private static int ey; private static int[][] ary; private static boolean[][] is; public static void main(String[] args) throws Exception { h = sc.nextInt(); w = sc.nextInt(); sx = sc.nextInt()-1; sy = sc.nextInt()-1; ex = sc.nextInt()-1; ey = sc.nextInt()-1; ary = new int[h][w]; is = new boolean[h][w]; for (int i = 0;i < h;i++) { String s = sc.next(); for (int j = 0;j < w;j++) { ary[i][j] = Integer.parseInt(s.substring(j, j+1)); } } if (move(sx, sy)) { System.out.println("YES"); } else { System.out.println("NO"); } } private static boolean move(int x, int y) { if (x == ex && y == ey) return true; int[] dx = {-1, 0, 1, 0, -2, 0, 2, 0}; int[] dy = {0, 1, 0, -1, 0, 2, 0, -2}; int height = ary[x][y]; is[x][y] = true; for (int i = 0;i < 8;i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (0 <= nx && nx < h && 0 <= ny && ny < w && !is[nx][ny]) { int nheight = ary[nx][ny]; boolean m = false; if (i < 4) { m = (height-1 <= nheight && nheight <= height+1); } else { int iheight = ary[x+dx[i-4]][y+dy[i-4]]; m = (height == nheight && iheight < height); } if (m) { if (move(nx, ny)) { return true; } } } } return false; } }