#include<bits/stdc++.h>
using namespace std;
int n,a[105][105],ha,la,hb,lb;
int fx[4] = {0,1,0,-1},fy[4] = {1,0,-1,0};
int v[105][105];
bool ans = false;
void fds(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&&a[tx][ty]==0&&v[tx][ty] == 0)
{
if(tx== hb &&ty == lb)
{
ans = true;
return;
}
fds(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;
}
fds(ha,la);
if(ans)
{
cout << "YES";
}
else
{
cout << "NO";
}
return 0;
}
/**************************************************************
Problem: 1430
User: yangwanning
Language: C++
Result: Accepted
Time:20 ms
Memory:2160 kb
****************************************************************/