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
36
37
38
#include <bits/stdc++.h>
using namespace std;

int w[100001], l[100001];
int t,n,m;
int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%d%d", &n, &m);
		for (int i = 1; i <= n; i++) {
			l[i] = w[i] = 0;
		}
		for (int i = 0; i < m; i++) {
			int a,b; char c;
			scanf("%d %c %d", &a, &c, &b);
			int *q = (c == '>') ? l : w;
			q[b]++;
		}
		bool ret = false;
		for (int i = 1; i <= n; i++) {
			if (l[i] == n) {
				printf("WYGRANA\n");
				ret=true;
				break;
			}
		}
		if (ret) continue;
		for (int i = 1; i <= n; i++) {
			if (w[i] == 0) {
				printf("REMIS\n");
				ret=true;
				break;
			}
		}
		if (!ret)
			printf("PRZEGRANA\n");
	}
}