#include<bits/stdc++.h> using namespace std; const int maxn=1e4+50; struct point { int id,p,d; }; int pos[maxn]; point a[maxn],b[maxn]; int cmp(point a,point b) { return a.p<b.p; } int main() { int l,t,n,Case,cas=0; scanf("%d",&Case); while(Case--) { printf("Case #%d:\n",++cas); scanf("%d%d%d",&l,&t,&n); for(int i=0; i<n; i++) { char ch; int x,dir; scanf("%d %c",&x,&ch); if(ch=='L') dir=-1; else dir=1; b[i].p=x+t*dir; a[i].id=i;a[i].p=x; b[i].d=dir;a[i].d=dir; } sort(a,a+n,cmp); sort(b,b+n,cmp); for(int i=0; i<n; i++) pos[a[i].id]=i; for(int i=0; i<n-1; i++) if(b[i].p==b[i+1].p) b[i].d=b[i+1].d=0; for(int i=0; i<n; i++) { int num=pos[i]; if(b[num].p<0||b[num].p>l) printf("Fell off\n"); else { printf("%d ",b[num].p); if(b[num].d==0) printf("Turning\n"); else if(b[num].d==1) printf("R\n"); else printf("L\n"); } } printf("\n"); } return 0; }