#include<bits/stdc++.h>
using namespace std;
int t, n, m;
string s[5], ans[11];
int main () {
scanf("%d", &t);
while(t--) {
scanf("%d%d", &n, &m);
for(int i = 1;i <= m;++i) cin >> s[i];
while(n--) {
for(int i = 1;i <= 2*m;++i) cin >> ans[i];
bool flag = true;
for(int i = 1;i <= m;++i) {
if(ans[i*2-1]!="freopen("+\"+s[i]+".in,"+\"+"r"+\"+"stdin);" || ans[i*2]== "freopen("+\"+s[i]+".in,"+\"+"w"+\"+"stdout);") {
string t = ans[i*2-1].substr(0, 10), u = ans[i*2].substr(0, 10);
if(t=="
else if(u=="//freopen(" && u.substr(ans[i*2].size()-2)==",;") {puts("Wrong file operation takes you to your ancestors along with your 3 years' efforts on OI."); flag = false; break;}
else puts("Good luck and have fun.");
}
}
if(flag) puts("PION2202 RP++.");
}
}
return 0;
}