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
39
40
41
42
43
44
45
46
47
48
#include <cstdio>

const int N = 200 * 1000 + 5;
int deg_in[N];
int deg_out[N];

int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		int n, m;
		scanf("%d%d", &n, &m);
		
		for (int i = 1; i <= n; i++)
			deg_in[i] = deg_out[i] = 0;
		
		for (int i = 0; i < m; i++) {
			int a, b;
			char z[2];
			scanf("%d%s%d", &a, z, &b);
			
			if (z[0] == '>') {
				deg_in[b]++;
			}
			else {
				deg_out[b]++;
			}
		}
		
		int res = 2;
		for (int i = 1; i <= n; i++) {
			if (deg_out[i] == 0) {
				res = 0;
			}
			if (deg_in[i] == n) {
				res = 1;
				break;
			}
		}
		
		if (res == 0)
			printf("REMIS\n");
		if (res == 1)
			printf("WYGRANA\n");
		if (res == 2)
			printf("PRZEGRANA\n");
	}
}