#include <iostream>
#include <vector>
#include <string>
#define Me 0
#define Ene 1
using namespace std;
int T;
int pos[2][3];
int map[9][9];
int Distance(){
return abs(pos[0][0]-pos[0][1])+abs(pos[1][0]-pos[1][1]);
}
int GetMap(int i, int j){
if ( i < 0 || j < 0 || i >= 9 || j >= 9)
return -1;
else
return map[i][j];
}
const int dx[4] ={ 0, 1, 0,-1};
const int dy[4] ={-1, 0, 1, 0};
int main(){
cin >> T;
for (int i = 0; i < 2; i++){
cin >> pos[i][0] >> pos[i][1] >> pos[i][2];
}
for(int i = 0; i <9; i++)
for(int j = 0; j < 9; j++)
cin >> map[i][j];
if(Distance(pos) <= 2){
cout << 5 << endl;
return;
}
for(int i = 0; i < 4; i++){
if(GetMap(pos[0][0]+dx[i],pos[0][1]+dy[i]) == 2)
cout << i+1 << endl;
return;
}
for(int i = 0; i < 4; i++){
if(GetMap(pos[0][0]+dx[i],pos[0][1]+dy[i]) == 0)
cout << i+1 << endl;
return;
}
for(int i = 0; i < 4; i++){
if(GetMap(pos[0][0]+dx[i],pos[0][1]+dy[i]) != -1)
cout << i+1 << endl;
return;
}
}
Battle History