#include
#include
#include
#include
using namespace std;
#define FOR(i,b,e) for(int i=(b);i<=(e);i++)
#define FORE(i,b,e) for(int i=(b);i>=(e);i--)
#define maxnum 503
int n[33][33];
int v[33];
int y[33];
int *pn[33];
int pos[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int main()
{
#ifdef DEBUG_
ifstream fin("G:/1.txt");
#define cin fin
#endif
memset(v,0,sizeof(v));
memset(n,0,sizeof(n));
memset(y,0,sizeof(y));
char state[7];
FOR(i,0,4){
cin>>state;
FOR(j,0,5){
int num=i*6+j;
y[num]=(state[j]=='1')?0:1;
n[num][num]=1;
pn[num]=n[num];
if(num%6>0)n[num][num-1]=1;
if((num+1)%6>0)n[num][num+1]=1;
if(num-6>=0)n[num][num-6]=1;
if(num+6<30)n[num][num+6]=1;
}
}
int x=0,row=0;
for(x=0;x<30;x++,row++){
if(pn[row][x]==0){
FOR(j,row+1,29)
if(pn[j][x]){
swap(pn[row],pn[j]);
swap(y[row],y[j]);
break;
}
}
if(!pn[row][x]){
row--;
continue;
}
FOR(j,row+1,29){
if(!pn[j][x])continue;
FOR(k,0,29){
pn[j][k]^=pn[row][k];
}
y[j]^=y[row];
}
}
x=29;
row=(row==30)?29:row;
FORE(i,row,0){
while(pn[row][x-1]){
v[x]=1;
for(int j=i;j>=0;j--){
if(!pn[j][x])continue;
y[j]^=y[i];
pn[j][i]=0;
}
x--;
}
v[x]=y[x];
for(int j=i-1;j>=0;j--){
if(!pn[j][x])continue;
y[j]^=y[i];
pn[j][i]=0;
}
x--;
}
int sum=0;
FOR(i,0,29)
sum+=v[i];
cout<0,29)
if(v[i])
cout<6+1<<" "<6+1<cout<return 0;
}