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 <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5+5;

int n,m;
int l[MAXN], p[MAXN];

int main(){
int z;
scanf("%d", &z);
while(z--){
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; ++i)
		l[i] = 0, p[i] = 0;
	for (int i = 1; i <= m; ++i){
		int a, b;
		string s;
		scanf("%d", &a);
		cin >> s;
		scanf("%d", &b);
		if (s[0] == '>'){
			l[b]++;
		}
		else{
			p[b]++;
		}
	}
	bool czy = false;
	for (int i = 1; i <= n; ++i){
		if (l[i] == n){
			printf("WYGRANA\n");
			czy = true;
			break;
		}
	}
	if (czy)
		continue;
	for (int i = 1; i <= n; ++i){
		if (p[i] == 0)
			czy = true;
	}
	if (czy == false)
		printf("PRZEGRANA\n");
	else
		printf("REMIS\n");
}
}