int b[10][10];
vvi visited;
void rec(int i, int j, int n){
if(i >= n || i < 0 || j >=n || j < 0 || b[i][j] == 0)
return;
dbg2(i, j)
visited[i][j] = 1;
// back-track the sol’
b[i][j] = 0;
rec(i-2, j-1, n);
rec(i-2, j+1, n);
rec(i-1, j-2, n);
rec(i-1, j+2, n);
rec(i+1, j-2, n);
rec(i+1, j+2, n);
rec(i+2, j-1, n);
rec(i+2, j+1, n);
b[i][j] = 1;
}
void solve(){
inp(n);
for(int i =0; i<n; i++)
for(int j=0; j<n; j++)
cin>>b[i][j];
visited.assign(n, vector(n, 0));
rec(0,0,n);
int count = 0;
for(int i = 0; i<n; i++){
for(int j = 0; j<n; j++){
if(!visited[i][j] && b[i][j])
count++;
}
}
cout << count << endl;
}