#include<bits/stdc++.h>
using namespace std;
int n,ha,la,hb,lb,a[110][110];
int fx[4]={0,1,0,-1};
int fy[4]={1,0,-1,0};
bool f=false;
void dfs(int x,int y){
    a[x][y]=1;
     
    for(int i=0;i<=3;i++){
        int tx=x+fx[i];
        int ty=y+fy[i];
        if(tx>=1&&tx<=n&&ty>=1&&ty<=n&&a[tx][ty]==0){
            if(tx==hb&&ty==lb){
                f=true;
            }else{
                dfs(tx,ty);
            }
             
        }
    }
     
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    cin>>ha>>la>>hb>>lb;
    if(a[ha][la]==1||a[hb][lb]==1){
        cout<<"NO";
    }else{
            dfs(ha,la);
            if(f==true) cout<<"YES";
            else cout<<"NO";
    }
 
    return 0;
}
 
/**************************************************************
	Problem: 1430
	User: panyuchen
	Language: C++
	Result: Accepted
	Time:21 ms
	Memory:2120 kb
****************************************************************/