#include<windows.h>
#define GOAWAY gotoxy(30,20);printf(" ");gotoxy(30,20);
#define gotoxy(x,y) SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){2*(x),(y)})
#define drawo(x) gotoxy((x)%19,(x)/19);printf("〇")
#define drawx(y) gotoxy((y)%19,(y)/19);printf("×")
using namespace std;
short brd[361],now,*iter,hehe,x,y;
int main(){
for(now=0;now!=19;++now) {
printf(" ");
printf("%d\n",(now)%10);
}
printf("0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8");
iter=brd+361;now=hehe=0;
while(iter!=brd) *--iter=0;
while(1){
do{
GOAWAY;
scanf("%d",&x);scanf("%d",&y);
now=x*19+y;
}
while((now>360||hehe>18)||brd[now]);
drawx(now);brd[now]=1;
while(x&&brd[y*19+(--x)]==1) ++hehe;x+=hehe;
while(x!=18&&brd[y*19+(++x)]==1) ++hehe;
if(hehe>3) break;hehe=0;
while(y&&brd[(--y)*19+x]==1) ++hehe;now+=hehe;
while(y!=18&&brd[(++y)*19+x]==1) ++hehe;
if(hehe>3) break;hehe=0;
do{
GOAWAY;
scanf("%d",&x);scanf("%d",&y);
now=19*y+x;
}
while((now>360||hehe>18)||brd[now]);
drawo(now);brd[now]=2;
}
}