#include<iostream>
#include<string.h>
using namespace std;
int FS1[110], FS2[110], FR1[110], FR2[110];
int FS3[110][110], FR3[110][110];
int n, m, r, s, x, y, num1, num2;
void inputFS(int a, int b) {
if (!a && !b) {
int tempx, tempy = r;
for (int i = 0; i < n; i++) {
if (FS2[i] < tempy) {
tempy = FS2[i];
tempx = FS1[i];
} else if (FS2[i] == tempy) {
if (FS1[i] < tempx) {
tempy = FS2[i];
tempx = FS1[i];
}
}
}
num1--;
x = tempx;
y = tempy;
FS3[x][y] = 1;
} else {
int Y = b;
for (int i = 0; i < n; i++) {
if (FS1[i] == a) {
if (FS2[i] > Y && !FS3[a][FS2[i]]) {
Y = FS2[i];
}
}
}
y = Y;
if (y == b) {
x = 0, y = 0;
} else {
FS3[x][y] = 1;
num1--;
}
}
if (num1 == 0) {
cout << "FS wins!" << endl;
}
}
void inputFR(int a, int b) {
if (!a && !b) {
int tempx, tempy = r;
for (int i = 0; i < n; i++) {
if (FR2[i] < tempy) {
tempy = FR2[i];
tempx = FR1[i];
} else if (FR2[i] == tempy) {
if (FR1[i] < tempx) {
tempy = FR2[i];
tempx = FR1[i];
}
}
}
num2--;
x = tempx;
y = tempy;
FR3[x][y] = 1;
} else {
int Y = b;
for (int i = 0; i < n; i++) {
if (FR1[i] == a) {
if (FR2[i] > Y && !FR3[a][FR2[i]]) {
Y = FR2[i];
}
}
}
y = Y;
if (y == b) {
x = 0, y = 0;
}else{
FR3[x][y] = 1;
num2--;
}
}
if (num2 == 0) {
cout << "FR wins!" << endl;
}
}
int main() {
int T;
cin >> T;
for (int j = 1; j <= T; j++) {
cin >> n >> m >> r >> s;
for (int i = 0; i < n; i++) {
cin >> FS1[i];
}
for (int i = 0; i < n; i++) {
cin >> FS2[i];
}
for (int i = 0; i < n; i++) {
cin >> FR1[i];
}
for (int i = 0; i < n; i++) {
cin >> FR2[i];
}
x = 0, y = 0;
num1 = n, num2 = n;
memset(FS3, 0, sizeof(FS3));
memset(FR3, 0, sizeof(FR3));
while (1) {
if (s == 1) {
inputFS(x, y);
s = 2;
} else {
inputFR(x, y);
s = 1;
}
if (num1 == 0 || num2 == 0) {
break;
}
}
}
return 0;
}