package work;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class A2632 {
static int T, A, B, N, M;
static int[] X;
static int[] Y;
static int[] stad;
static char direc;
static int robnum, moved, time;
public static void main(String[] args) throws FileNotFoundException {
/* Scanner sc=new Scanner(System.in); */
Scanner sc = new Scanner(new File("src/2632.txt"));
T = sc.nextInt();
for (int t = 0; t < T; t++) {
A = sc.nextInt();
B = sc.nextInt();
N = sc.nextInt();
M = sc.nextInt();
X = new int[N];
Y = new int[N];
stad = new int[N];
for (int i = 0; i < N; i++) {
X[i] = sc.nextInt();
Y[i] = sc.nextInt();
direc = sc.next().charAt(0);
if (direc == 'E')
stad[i] = 0;
else if (direc == 'S')
stad[i] = 1;
else if (direc == 'W')
stad[i] = 2;
else if (direc == 'N')
stad[i] = 3;
}
boolean flag = false;
for (int i = 0; i < M; i++) {
robnum = sc.nextInt();
moved = sc.next().charAt(0);
time = sc.nextInt();
if (moved == 'F') {
if (!flag) {
for (int j = 0; j < time; j++) {
if (stad[robnum] == 0)
X[robnum]++;
else if (stad[robnum] == 1)
Y[robnum]--;
else if (stad[robnum] == 2)
X[robnum]--;
else if (stad[robnum] == 3)
Y[robnum]++;
flag = jude(robnum);
if (flag)
break;
}
} else if (moved == 'L')
stad[robnum] = (stad[robnum] - time % 4 + 4) % 4;
else if (moved == 'R')
stad[robnum] = (stad[robnum] + time % 4) % 4;
}
if (!flag)
System.out.println("OK");
}
}
}
private static boolean jude(int k) {
if (X[k] <= 0 || X[k] > A || Y[k] <= 0 || Y[k] > B) {
System.out.println("Robot " + k + " crashes into the wall");
return true;
}
for (int i = 0; i < N; i++) {
if (i == k)
continue;
if (X[k] == X[i] && Y[k] == Y[i]) {
System.out.println("Robot " + k + " crashes into robot " + "i");
return true;
}
}
return false;
}
}
//
4
5 4
2 2
1 1 E
5 4 W
1 F 7
2 F 7
5 4
2 4
1 1 E
5 4 W
1 F 3
2 F 1
1 L 1
1 F 3
5 4
2 2
1 1 E
5 4 W
1 L 96
1 F 2
5 4
2 3
1 1 E
5 4 W
1 F 4
1 L 1
1 F 20
//
Robot 1 crashes into the wall
OK