#include #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define FORR(i,a,b) for (int i=(a);i>=(b);i--) #define pb push_back #define pcnt __builtin_popcount #define show(x) cout<<#x<<" = "< pii; typedef vector vi; typedef vector vvi; typedef vector vpii; typedef set si; typedef pair pll; typedef vector vl; typedef vector vvl; typedef vector vpll; typedef set sl; templatestring join(vector&v) {stringstream s;FOR(i,0,sz(v))s<<' '<b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;} int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;} void dout(double d){printf("%.12f\n",d);} const int iinf = 1e9; const ll linf = 1e18; const int mod = 1e9+7; const double pi = acos(-1); const double eps = 1e-10; typedef pair ti; int h, w, s[3], g[3], sn[50][50]; bool y[3000][50][50], de; set gl; queue q; ti gt; vpii v; main(){ cin.tie(0); ios::sync_with_stdio(false); v.pb(mp(-1, 0)); v.pb(mp( 1, 0)); v.pb(mp( 0,-1)); v.pb(mp( 0, 1)); cin >> h >> w; FOR(i, 0, 3)cin >> s[i]; FOR(i, 0, 3)cin >> g[i]; if(abs(s[1]+s[2]-g[1]-g[2])%2 != abs(s[0]-g[0])%2){ cout << "No" << endl; return 0; } gt = mp(g[0], mp(g[1], g[2])); FOR(i, 0, h){ string s; cin >> s; FOR(j, 0, w)sn[i][j] = (s[j] == '*' ? 1 : -1); } FOR(i, 0, h)FOR(j, 0, w){ if(i < h-1){ if(sn[i][j]>0 && sn[i+1][j]>0){ gl.insert(mp(i, j)); gl.insert(mp(i+1, j)); } if(sn[i][j] < 0 && sn[i+1][j] < 0) de = true; } if(j < w-1){ if(sn[i][j]>0 && sn[i][j+1]>0){ gl.insert(mp(i, j)); gl.insert(mp(i, j+1)); } if(sn[i][j] < 0 && sn[i][j+1] < 0) de = true; } } if((!de) && s[0] - g[0] > 1){ cout << "No" << endl; return 0; } q.push(mp(s[0], mp(s[1], s[2]))); y[s[0]][s[1]][s[2]] = true; ti tmp; int _x, _y, _z; while(!q.empty()){ tmp = q.front(); if(tmp == gt){ cout << "Yes" << endl; return 0; } q.pop(); each(itr, v){ _x = tmp.se.fi + itr->fi; _y = tmp.se.se + itr->se; if(0 <= _x && _x < h && 0 <= _y && _y < w){ _z = tmp.fi + sn[_x][_y]; if(_z < 1 || _z > 1500 || y[_z][_x][_y])continue; q.push(mp(_z, mp(_x, _y))); y[_z][_x][_y] = true; } } } cout << "No" << endl; return 0; }