import java.io.PrintStream; import java.util.Scanner; public class Y424 { int h, w, sx, sy, tx, ty; String[] s; boolean[][] visited; static int[] dx = { 0, 1, 0, -1 }; static int[] dy = { 1, 0, -1, 0 }; Y424() throws Exception { Scanner in = new Scanner(System.in); PrintStream out = new PrintStream(System.out); h = in.nextInt(); w = in.nextInt(); sx = in.nextInt(); sy = in.nextInt(); tx = in.nextInt(); ty = in.nextInt(); s = new String[h]; for (int i = 0; i < h; i++) { s[i] = in.next(); } visited = new boolean[h][w]; visited[sx-1][sy-1] = true; dfs(sx-1, sy-1); if (visited[tx-1][ty-1]) { out.println("YES"); } else { out.println("NO"); } out.flush(); } void dfs(int x, int y) { for (int dir = 0; dir < 4; dir++) { int xx = x + dx[dir]; int yy = y + dy[dir]; if (0 <= xx && xx < h && 0 <= yy && yy < w) { if (Math.abs((int)s[xx].charAt(yy) - (int)s[x].charAt(y)) <= 1 && !visited[xx][yy]) { visited[xx][yy] = true; dfs(xx, yy); } int xxx = x + 2 * dx[dir]; int yyy = y + 2 * dy[dir]; if (0 <= xxx && xxx < h && 0 <= yyy && yyy < w) { if (s[x].charAt(y) == s[xxx].charAt(yyy) && (int)s[x].charAt(y) > (int)s[xx].charAt(yy)) { if (!visited[xxx][yyy]) { visited[xxx][yyy] = true; dfs(xxx, yyy); } } } } } } public static void main(String argv[]) throws Exception { new Y424(); } }