import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); int start = (sc.nextInt() - 1) * w + sc.nextInt() - 1; int goal = (sc.nextInt() - 1) * w + sc.nextInt() - 1; StringBuilder sb = new StringBuilder(); for (int i = 0; i < h; i++) { sb.append(sc.next()); } ArrayList> graph = new ArrayList<>(); for (int i = 0; i < h * w; i++) { graph.add(new ArrayList<>()); } char[] field = sb.toString().toCharArray(); for (int i = 0; i < h; i++) { int[] idxes = new int[10]; Arrays.fill(idxes, -1); int prev = -10; for (int j = 0; j < w; j++) { int x = i * w + j; int tmp = field[x] - '0'; if (Math.abs(prev - tmp) == 1) { graph.get(x - 1).add(x); graph.get(x).add(x - 1); } if (idxes[tmp] != -1) { graph.get(x).add(idxes[tmp]); graph.get(idxes[tmp]).add(x); } idxes[tmp] = x; for (int k = tmp - 1; k >= 0; k--) { idxes[k] = -1; } prev = tmp; } } for (int i = 0; i < w; i++) { int[] idxes = new int[10]; Arrays.fill(idxes, -1); int prev = -10; for (int j = 0; j < h; j++) { int x = i + j * w; int tmp = field[x] - '0'; if (Math.abs(prev - tmp) == 1) { graph.get(x - w).add(x); graph.get(x).add(x - w); } if (idxes[tmp] != -1) { graph.get(x).add(idxes[tmp]); graph.get(idxes[tmp]).add(x); } idxes[tmp] = x; for (int k = tmp - 1; k >= 0; k--) { idxes[k] = -1; } prev = tmp; } } ArrayDeque deq = new ArrayDeque<>(); deq.add(start); boolean[] visited = new boolean[h * w]; while (deq.size() > 0) { int x = deq.poll(); if (visited[x]) { continue; } visited[x] = true; deq.addAll(graph.get(x)); } if (visited[goal]) { System.out.println("YES"); } else { System.out.println("NO"); } } }