#define _CRT_SECURE_NO_WARNINGS // #define _GLIBCXX_DEBUG #include using namespace std; template ostream &operator << (ostream &os, const vector &); template typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple &){} template typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple &t){ os << (n == 0 ? "" : " ") << get(t); _ot(os, t); } template ostream &operator << (ostream &os, const tuple &t){ _ot<0>(os, t); return os; } template ostream & operator << (ostream &os, const pair &p){ return os << "(" << p.first << ", " << p.second << ") "; } template ostream &operator << (ostream &os, const vector &v){ for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os; } #ifdef DEBUG #define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \ << " (L : " << __LINE__ << ")" << endl) #else #define dump(...) #endif #define all(c) begin(c), end(c) #define range(i,a,b) for(int i = a; i < (int)(b); i++) #define rep(i,b) range(i,0,b) #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple using ll = long long; // #define int ll using vi = vector; using vvi = vector; using pii = pair; void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); } int const mod = 1000000007; auto const inf = numeric_limits::max()/8; int h,w; int g[55][55]; int a,si,sj; int b,gi,gj; int memo[55][55][2000]; int solve(){ using State = tuple; fill((int*)begin(memo), (int*)end(memo), 0); queue q; q.emplace(si,sj,a); while(q.size()){ int ci,cj,cs; tie(ci,cj,cs) = q.front(); q.pop(); if(memo[ci][cj][cs]) continue; memo[ci][cj][cs] = true; if(ci == gi && cj == gj && b == cs) return true; int dir[4][2] = { {0,1}, {1,0}, {0,-1}, {-1,0} }; for(auto d : dir){ int ni = ci + d[0]; int nj = cj + d[1]; if(ni >= h || nj >= w || ni < 0 || nj < 0) continue; int ns = cs + g[ni][nj]; if(memo[ni][nj][ns]) continue; if(ns <= 0 || ns >= 2000) continue; q.emplace(ni, nj, ns); } } return false; } int main(){ while(cin >> h >> w){ cin >> a >> si >> sj; cin >> b >> gi >> gj; rep(i,h){ string s; cin >> s; rep(j,w){ g[i][j] = s[j] == '*' ? 1 : -1; } } puts(solve() ? "Yes" : "No"); } }