/*
#include <stdio.h>
int main()
{
int s[120][120];
int r,c,i,j,m,n,k=0;
for (i=1; i<=9; i++){
for (j=1; j<=9; j++){
scanf("%d",&s[i][j]);
}
}
scanf("%d %d",&r,&c);
for (m=r-1; m<=r+1; m++){
for (n=c-1; n<=c+1; n++){
if (s[m][n]==1){
k++;
}
}
}
if(s[r][c]==1){
printf("-1");
}
else{
printf("%d",k);
}
}
*/