1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# include <bits/stdc++.h>
using namespace std;
const int MN = 1e5 + 44;
int wdeg[MN];
int ldeg[MN];
void solve() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		char d[2];
		scanf("%d%s%d", &a, d, &b);
		if (d[0] == '>')
			wdeg[b]++;
		else
			ldeg[b]++;
	}
	
	int win = false, loss = true;
	for (int i = 1; i <= n; ++i) {
		if (wdeg[i] == n)
			win = true;
		if (ldeg[i] == 0)
			loss = false;
	}
	if (win) printf("WYGRANA\n");
	else if (loss) printf("PRZEGRANA\n");
	else printf("REMIS\n");
	for (int i = 1; i <= n; ++i) wdeg[i] = ldeg[i] = 0;
}
int main() {
	int t;
	scanf("%d", &t);
	while (t--) solve();
}