#include<bits/stdc++.h>
using namespace std;
int n;
int a[110][110];
int ha,la;//a
int hb,lb;//b
int fx[4]={0,1,0,-1};
int fy[4]={1,0,-1,0};
bool f=false;
void dfs(int x,int y){
	if(x==hb&&y==lb){
		f=true;
		exit(0);
	}
	for(int i=1;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]==1){
			a[x][y]=1;
			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;
	dfs(ha,la);
	if(f==true){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
    return 0;
}

/**************************************************************
	Problem: 1430
	User: zengdongxin
	Language: C++
	Result: Memory Limit Exceed
****************************************************************/