#include using namespace std; typedef long long int ll; vector> swapper; int turnTableRX[3][3]={{0,0,0},{1,0,-1},{0,0,0}}; int turnTableRY[3][3]={{0,-1,0},{0,0,0},{0,1,0}}; int vx=0,vy=1; int px=0,py=0; bool target=false; int tx,ty; map,int> field; void print(){ int x,y; for (y=-3;y<3;y++){ for (x=-3;x<3;x++){ pair p=make_pair(x,y); if (px==x&&py==y) cout<<"[";else cout<<" "; if (field.count(p)){ cout << field[p]; }else{ cout << "?"; } if (px==x&&py==y) cout<<"]";else cout<<" "; } cout< p=make_pair(x,y); return field.count(p) && field[p]; } inline void turnLeft(){ int x=vx,y=vy; vx=-turnTableRX[x+1][y+1]; vy=-turnTableRY[x+1][y+1]; } inline void turnRight(){ int x=vx,y=vy; vx=turnTableRX[x+1][y+1]; vy=turnTableRY[x+1][y+1]; } inline bool isKnown(int x,int y){ return field.count(make_pair(x+1,y)) && field.count(make_pair(x-1,y)) && field.count(make_pair(x,y+1)) && field.count(make_pair(x,y-1)) ; } void finalAction(){ int l;string buff; do{ puts("F\n"); cin >> buff; }while(buff[0]!='M'); exit(0); } void check(){ int l,i; if (scanf("%d",&l)<=0) exit(0); if (l==20151224) finalAction(); for (i=1;i<=l;i++){ field[make_pair(px+vx*i,py+vy*i)]=1; } field[make_pair(px+vx*i,py+vy*i)]=0; } void action(){ int b; if (target){ // 使ってない }else{ if (isKnown(px,py)){ map,bool> dp; queue> q; if (moveable(px-1,py)) q.push(vector{px-1,py,-1,0}); if (moveable(px+1,py)) q.push(vector{px+1,py,1,0}); if (moveable(px,py-1)) q.push(vector{px,py-1,0,-1}); if (moveable(px,py+1)) q.push(vector{px,py+1,0,1}); while (!q.empty()){ vector &v=q.front(); dp[make_pair(v[0],v[1])]=true; if (isKnown(v[0],v[1])){ if (!dp.count(make_pair(v[0]+1,v[1])) && moveable(v[0]+1,v[1])) q.push(vector{v[0]+1,v[1],v[2],v[3]}); if (!dp.count(make_pair(v[0]-1,v[1])) && moveable(v[0]-1,v[1])) q.push(vector{v[0]-1,v[1],v[2],v[3]}); if (!dp.count(make_pair(v[0],v[1]+1)) && moveable(v[0],v[1]+1)) q.push(vector{v[0],v[1]+1,v[2],v[3]}); if (!dp.count(make_pair(v[0],v[1]-1)) && moveable(v[0],v[1]-1)) q.push(vector{v[0],v[1]-1,v[2],v[3]}); }else{ // target=true; // tx=v[0];ty=v[1]; // action(); if (v[2]==vx && v[3]==vy){ puts("F\n"); px+=vx;py+=vy; }else{ if (turnTableRX[vx+1][vy+1]==v[2] && turnTableRX[vx+1][vy+1]==v[3]){ puts("R\n"); turnRight(); }else{ puts("L\n"); turnLeft(); } } break; } q.pop(); } }else{ puts("R\n"); turnRight(); } } } int main(){ field[make_pair(0,0)]=1; while (true){ check(); action(); //print(); } return 0; }