#include<cstdio>
#include<iostream>
#define N 5
using namespace std;
struct note
{
int x,y,pre;
}que[100];
int maze[N][N];
int Nx[4]={1,-1,0,0};
int Ny[4]={0,0,-1,1};
int start=0,end=1;
void print(int s)
{
if(que[s].pre!=-1)
{
print(que[s].pre);
cout<<"("<<que[s].x<<", "<<que[s].y<<")"<<endl;
}
}
void bfsMaze(int x,int y)
{
que[start].pre=-1;
que[start].x=x;
que[start].y=y;
while(start<end)
{
for(int i=0;i<4;i++)
{
int a=Nx[i]+que[start].x;
int b=Ny[i]+que[start].y;
if(a<0 || b<0 || a>=N || b>=N || maze[a][b])
continue;
else
{
maze[a][b]=-1;
que[end].pre=start;
que[end].x=a;
que[end].y=b;
end++;
}
if(a==N-1 && b==N-1)
print(start);
}
start++;
}
}
int main()
{
int i,j;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
scanf("%d",&maze[i][j]);
cout<<"(0, 0)"<<endl;
bfsMaze(0,0);
cout<<"("<<N-1<<", "<<N-1<<")"<<endl;
return 0;
}