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

/**************************************************************
	Problem: 1430
	User: linzihang
	Language: C++
	Result: Accepted
	Time:17 ms
	Memory:2160 kb
****************************************************************/