char*t,a[9][999],*p,*m;i;main(s){m=p=a[8]+400;while(gets(a[i++]));for(;s+29;s=t[2]-64)t=a[*p?*p-47:1]+s*4,*p=*t,t[1]-60?p++:p--,m=p