#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
const int N = 2010;
typedef long long LL;
int n, m;
int main(){
int T;
cin >> T;
while (T -- ){
cin >> n >> m;
if (n % (m + 1) == 0)
puts("second");
else
puts("first");
}
return 0;
}
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
const int N = 2010;
typedef long long LL;
int n, m;
int main(){
while (cin >> n){
if (n % 3 == 0)
puts("Cici");
else
puts("Kiki");
}
return 0;
}
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
const int N = 1010;
typedef long long LL;
int sg[N], s[15];
bool st[N];
int n;
void get_sg(){
for (int i = 0; i < N; i ++ ){
memset(st, false, sizeof st);
for (int j = 0; j <= 10 && s[j] <= i; j ++ )
st[sg[i - s[j]]] = true;
for (int j = 0; j < N; j ++ )
if (!st[j]){
sg[i] = j;
break;
}
}
}
int main(){
for (int i = 0; i <= 10; i ++ ) s[i] = 1 << i;
get_sg();
while (cin >> n){
if (sg[n])
puts("Kiki");
else
puts("Cici");
}
return 0;
}
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
const int N = 10010;
typedef long long LL;
int k, m, n;
int s[N], sg[N];
bool st[N];
void get_sg(){
memset(sg, 0, sizeof sg);
for (int i = 0; i < N; i ++ ){
memset(st, false, sizeof st);
for (int j = 0; j < k && s[j] <= i; j ++ )
st[sg[i - s[j]]] = true;
for (int j = 0; j < N; j ++ )
if (!st[j]){
sg[i] = j;
break;
}
}
}
int main(){
while (cin >> k && k){
for (int i = 0; i < k; i ++ ) cin >> s[i];
sort(s, s + k);
get_sg();
cin >> m;
while (m -- ){
int ans = 0;
cin >> n;
while (n -- ){
int x;
cin >> x;
ans ^= sg[x];
}
if (!ans)
cout << "L";
else
cout << "W";
}
cout << endl;
}
return 0;
}