using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; static class Program{ const int mod=(int)1e9+7; static readonly int[][] di1=new int[][]{new int[]{-1,0},new int[]{1,0},new int[]{0,1},new int[]{0,-1}}; static char[][] bm; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; int h=s[0],w=s[1]; char c='#'; var a=sc.Ia; var t=sc.Ia; int sx=t[0],sy=t[1]; bm=new char[h+2][]; var b=new long[h+2][]; for(int i = 1;i<=h;i++) { bm[i]=(c+sc.S+c).ToCharArray(); b[i]=new long[w+2]; } bm[0]=bm[h+1]=new string(c,w+2).ToCharArray(); b[0]=b[h+1]=new long[w+2]; var pq=new Rheap<(int,int)>(32); pq.Push(new Rheap<(int,int)>.Dt(1,(sy,sx))); b[sy][sx]=1; while(pq.cnt>0){ var e=pq.Dequeue; if(e.d.Item1==t[2]&&e.d.Item2==t[3]){ if(e.n-1>a[4]){ Console.WriteLine("No"); } else{ Console.WriteLine("Yes"); } return; } if(b[e.d.Item1][e.d.Item2]!=e.n){continue;} Fdi(e.d.Item1,e.d.Item2,(y,x,z)=>{ if(bm[y][x]=='.'&&(b[y][x]==0||b[y][x]>e.n+a[z])){ pq.Push(new Rheap<(int,int)>.Dt(e.n+a[z],(y,x))); b[y][x]=e.n+a[z]; } else if(bm[y][x]=='@'&&(b[y][x]==0||b[y][x]>e.n+a[z]+a[5])){ pq.Push(new Rheap<(int,int)>.Dt(e.n+a[z]+a[5],(y,x))); b[y][x]=e.n+a[z]+a[5]; } }); } Console.WriteLine("No"); } static void Fdi(int y,int x,Action f){for(int i=0;i<4;i++){f(y+di1[i][0],x+di1[i][1],i);}} } public class Rheap{ public class Dt{ public long n; public T d; public Dt(long n,T d){this.n=n;this.d=d;} public override string ToString()=>"d:"+d.ToString()+" n:"+n.ToString(); } private const int m=65; private long la=0; private Dt[][] bf; private int[] h; public int cnt=0; public Rheap(int max){ bf=new Dt[m][]; h=new int[m]; for(int i = 0;i0){ int p=0; for(int j = 1;jbf[i][j].n){p=j;} } la=bf[i][p].n; for(int j = 0;j(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i