void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.container, std.typecons; int h, w; rd(h, w); int a, si, sj; rd(a, si, sj); int b, gi, gj; rd(b, gi, gj); auto mat=new char[][](h, w); foreach(i; 0..h) mat[i]=readln.chomp.to!(char[]); alias T=Tuple!(int, "sz", int, "i", int, "j"); auto dir=[[0, 1], [0, -1], [1, 0], [-1, 0]]; auto vis=new bool[][][](2000, h, w); auto Q=new DList!(T)(T(a, si, sj)); while(!Q.empty){ auto cur=Q.front; Q.removeFront; if(cur.sz==b && cur.i==gi && cur.j==gj){writeln("Yes"); return;} foreach(d; dir){ auto ni=cur.i+d[0], nj=cur.j+d[1]; if(ni<0 || nj<0 || ni>=h || nj>=w) continue; auto nsz=cur.sz+(mat[ni][nj]=='*'?1:-1); if(nsz>0 && nsz<2000 && !vis[nsz][ni][nj]){ vis[nsz][ni][nj]=true; Q.insertFront(T(nsz, ni, nj)); } } } writeln("No"); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } }