// ant.cpp
#include <iostream>
using namespace std;
int main(void){
int N=5;
int **G= new int*[N];
for(int i=0;i<N;i++) G[i] = new int[N];
for(int j=0;j<N;j++){
for(int k=0;k<N;k++){
G[j][k]=1;
}
}
int mold=3;int nold=2;int mnew=2;int nnew=2;
int t=0;int T=40;
while(t<T){
if((mnew<mold)&&(nnew==nold)){
G[mnew][nnew]=-G[mnew][nnew];
mold=mnew;nold=nnew;nnew=(nnew+1)%N;goto L;
}
if((mnew==mold)&&(nnew<nold)){
G[mnew][nnew]=-G[mnew][nnew];
mold=mnew;
nold=nnew;
mnew=(mnew+1)%N;goto L;
}
if((mnew>mold)&&(nnew==nold)){
G[mnew][nnew]=-G[mnew][nnew];
mold=mnew;nold=nnew;nnew=(nnew-1+N)%N;goto L;
}
if((mnew==mold)&&(nnew>nold)){
G[mnew][nnew]=-G[mnew][nnew];
mold=mnew;nold=nnew;mnew=(mnew-1+N)%N;goto L;
}
L:
cout<<mnew<<" "<<nnew<<" "<<G[mnew][nnew]<<endl;
t++;
}
for(int l=0;l<N;l++) delete[] G[1];delete[] G;
return 0;
}