#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <set> #include <bitset> using namespace std; typedef bitset<2550> bits; int main(){ int h,w; cin >> h >> w; vector<int> a(2),r(2),c(2); for(int i=0; i<2; i++) cin >> a[i] >> r[i] >> c[i]; vector<string> m(h); for(int i=0; i<h; i++) cin >> m[i]; bits inc,dec; bits mask; for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ (m[i][j]=='.'?dec:inc).set( (w+1)*i + j ); mask.set( (w+1)*i + j ); } } int mx_size = 1200; int times = 1200; vector<bits> s(mx_size); s[a[0]].set( (w+1)*r[0] + c[0] ); for(int i=0; i<1200; i++){ for(int k=max(a[0]-i, 1); k<min(a[0]+i+1, mx_size); k++){ //for(int k=0; k<mx_size; k++){ bits tmp = (s[k]<<1) | (s[k]>>1) | (s[k]<<(w+1)) | (s[k]>>(w+1)) & mask; if(k+1<mx_size){ s[k+1] |= tmp & inc; } if(k-1>0){ s[k-1] |= tmp & dec; } } if(s[a[1]][(w+1)*r[1] + c[1]]){ cout << "Yes" << endl; return 0; } } if(s[a[1]][(w+1)*r[1] + c[1]]){ cout << "Yes" << endl; }else{ cout << "No" << endl; } return 0; }