#include <bits/stdc++.h>
using namespace std;
int n,m,sx,sy,fx,fy;
char a[50][50];//地图
int vis[50][50];//标记数组 判断是否走过
int dir[4][2] = {1,0,0,1,-1,0,0,-1};//方向数组
bool f = 0;//f是标记 0表示不通 1表示可以走通
bool check(int x,int y){//判断是否越界
return x>=1 && x<=n && y>=1 && y<=m;
}
void dfs(int x,int y){
if(xfx && yfy){//走到右下角,结束
f = 1;
return ;
}
for(int i=0;i<4;i++){//四个方向依次寻找
int nx = x + dir[i][0];
int ny = y + dir[i][1];
if(check(nx,ny) && a[nx][ny] != '#' && vis[nx][ny] == 0){
//未越界 && 可以走 && 未走过
vis[nx][ny] = 1;
dfs(nx,ny);
vis[nx][ny] = 0;
}
}
}
int main(){
cin>>n>>m;
cin>>sx>>sy>>fx>>fy;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
vis[1][1] = 1;
dfs(sx,sy);
if(f == 1) cout<<"YES";
else cout<<"NO";
return 0;
}