#include<time.h>
#include<stdio.h>
#include<conio.h>
char A[][20]={
"00000000000000000000",
"01::::::7::::::::200",
"0:000000:00000000:00",
"0:000000:00000000:00",
"0:000000:00000000:00",
"06::::::9:::7::::5::",
"0:000000:000:0000000",
"0:000000:0003::::200",
"03::::::800000000:00",
"00000000:0001::::9:7",
"00000000:000:000000:",
"00000000:000:01::::4",
"::::::::9:::803:::::",
"00000000:000:0000000",
"00000000:0006:::::::",
"00000000:000:0000000",
"01::::::9:::5::::200",
"0:000000:00000000:00",
"0:000000:00000000:00",
"03::20006::::::::5::",
"0000:000:00070000000",
"01::5:::40003::::200",
"0:000000000000000:00",
"03:::::::::::::::5::",
"00000000000000000000"};
char far*q=1960+(char far*)0xB8000000;
char far*Q[1000];
int b[1000],e[256];
int B[1000]={0,77,75,80,72};
int I[]={0,1,-1,b[479]=40,b[520]=-40};
int G[]={0,2,1,4,3,5,7,6,8,9,10};
int a=5,c=778,d=999;
int E,L,M,n,v,w,x,y;
int main(){
textmode(C40);
_setcursortype(_NOCURSOR);
clock_t T;
while(e[B[--a]]=a);
for(y=25;y--;a=0,q-=40)
for(d-=x=20;x--;)
B[++a+d]=G[B[d]=A[y][x]-48],
*(Q[d--]=q--)=*(Q[d+a]=--q+2*a)=!B[d],
*(q+2*a++)=*q=219;
Inicio:
T=clock();
while(clock()-T<4);
while(kbhit()) M=E=getch();
if(E==27&&getch()==E) return 0;
E=M;
do{
a=d=c+I[e[E]];
if(!B[d+=b[a]]) a=E!=L?E=L:0;
else L=E,
*Q[c]=a=0,
*Q[c=d]=14;
}while(a);
goto Inicio;
}