import java.util.*; import java.io.*; public class Main { private static int[] dy = {0,1,0,-1}; private static int[] dx = {1,0,-1,0}; private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws Exception { int[] h_w = readIntArray(); int h = h_w[0]; int w = h_w[1]; int[] aInfo = readIntArray(); int a = aInfo[0]; int si = aInfo[1]; int sj = aInfo[2]; int[] bInfo = readIntArray(); int b = bInfo[0]; int gi = bInfo[1]; int gj = bInfo[2]; boolean[][] field = new boolean[h][w]; for(int i = 0 ; i < h ; i++){ char[] terrains = br.readLine().toCharArray(); for(int j = 0 ; j < w ; j++){ if(terrains[j] == '*'){ field[i][j] = true; } } } boolean[][][] exist = new boolean[2000][h+1][w+1]; exist[a][si][sj] = true; String judge = bfs(field , a , si , sj , b , gi , gj , h , w , exist); System.out.println(judge); } private static String bfs(boolean[][] field , int firstVolume , int firstH , int firstW , int goalVolume , int goalH , int goalW , int h , int w , boolean[][][] exist){ ArrayDeque todo = new ArrayDeque<>(); todo.addLast(new Pair(firstVolume , firstH , firstW)); while(!todo.isEmpty()){ Pair p = todo.pollFirst(); int currentH = p.getY(); int currentW = p.getX(); for(int i = 0 ; i < 4 ; i++){ int nextH = currentH + dy[i]; int nextW = currentW + dx[i]; if(nextH < 0 || nextH >= h || nextW < 0 || nextW >= w){ continue; } int size = p.getSize(); if(field[nextH][nextW]){ size++; }else{ size--; } if(size >= 2000 || size <= 0){ continue; } if(exist[size][nextH][nextW]){ continue; } //System.out.println(size+":"+nextH+":"+nextW); exist[size][nextH][nextW] = true; todo.addLast(new Pair(size , nextH , nextW)); } } return exist[goalVolume][goalH][goalW] ? "Yes" : "No"; } private static int[] readIntArray() throws Exception{ int[] intArray = Arrays.stream(br.readLine().split(" ")) .mapToInt(Integer::parseInt).toArray(); return intArray; } } class Pair{ int size , y , x; public Pair(int size , int y , int x){ this.size = size; this.y = y; this.x = x; } public int getSize(){ return size; } public int getY(){ return y; } public int getX(){ return x; } }