#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
int dir[5][2] = {{0,0},{0,1},{-1,0},{0,-1},{1,0}};
struct robot{
    int x,y;
    int face;
}r[105];//1 N ,3 S, 2 W, 4 E
int map[105][105];
int main(){
   int t,a,b,n,m;
    scanf("%d",&t);
    while(t--){
        memset(map,0,sizeof(map));
        scanf("%d%d",&a,&b);
       scanf("%d%d",&n,&m);
       char tmp;
        for (int i = 1; i <= n; i++)
       {
         scanf("%d %d %c",&r[i].x,&r[i].y,&tmp);
            map[r[i].x][r[i].y] = i;
          if(tmp == 'N')r[i].face = 1;
           else if(tmp == 'S')r[i].face = 3;
            else if(tmp == 'W')r[i].face = 2;
           else if(tmp == 'E')r[i].face = 4;
      }
        int ind,rep,flag = 0;
        for (int i = 1; i <= m; i++)
        {
            scanf("%d %c %d",&ind,&tmp,&rep);
            if(flag){continue;}
            if(tmp == 'L'){
                for (int k = 0; k < rep; k++)
                {
                    if(r[ind].face == 4)r[ind].face = 1;
                   else r[ind].face ++;
                }
           }else if(tmp == 'R'){
                for (int k = 0; k < rep; k++)
               {
                    if(r[ind].face == 1)r[ind].face = 4;
                    else r[ind].face --;
                }
           }
		   else if(tmp == 'F')
		   {
                map[r[ind].x][r[ind].y] = 0;
               for (int k = 0; k < rep; k++)
               {
                    r[ind].x += dir[r[ind].face][0];
                    r[ind].y += dir[r[ind].face][1];
                   if(r[ind].x < 1 || r[ind].x > a){flag = 1;break;}
                   if(r[ind].y < 1 || r[ind].y > b){flag = 1;break;}
                  if(map[r[ind].x][r[ind].y]!=0){
                        flag = 2;
                        printf("Robot %d crashes into robot %d\n",ind,map[r[ind].x][r[ind].y]);
                        break;
                   }
                }
               if(flag == 1)printf("Robot %d crashes into the wall\n",ind);
                if(flag == 0)map[r[ind].x][r[ind].y] = ind;
           }
        }
        if(flag == 0)printf("OK\n");
    }
    return 0;
}
05-10 23:03