#include<bits/stdc++.h>
using namespace std;
int n,ha,la,hb,lb;
bool c=false;
int q[1000][1000];
void dfs(int a,int b){
q[a][b]=1;
int fx[4]={0,0,1,-1};
int fy[4]={-1,1,0,0};
for(int i=1;i<=4;i++){
int tx=a+fx[i];
int ty=b+fy[i];
if(tx>=1&&tx<=n&&ty>=1&&ty<=n&&q[tx][ty]==0){
if(tx==hb&&ty==lb) c=true;
dfs(tx,ty);
}
}
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>q[i][j];
}
}
cin>>ha>>la>>hb>>lb;
dfs(ha,la);
if(c==true){
cout<<"YES";
}
else{
cout<<"NO";
}
return 0;
}
/**************************************************************
Problem: 1430
User: chenyubo
Language: C++
Result: Runtime Error
****************************************************************/