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
49
50
51
52
53
54
55
56
57
58
59
#include<bits/stdc++.h>
using namespace std;

int n,m;

typedef pair<int,int> pii;
const int N = 1e5+77;

int cnt_lewe[N], cnt_prawe[N];

void wczytaj() {
	cin >> n >> m;
	int a,b;
	char c;
	for(int i=1;i<=n;i++) 
		cnt_lewe[i] = cnt_prawe[i] = 0;
	while(m--) {
		cin >> a >> c >>  b;
		if(c == '>')
			cnt_lewe[b]++;
		else {
			cnt_prawe[b]++;
		}
	}
}


int jebaj() {
	int q = 0;
	for(int i=1;i<=n;i++) if(cnt_lewe[i] == n)
		q++;

	int r = 0;
	for(int i=1;i<=n;i++)
		if(cnt_prawe[i] == 0)
			r++;
	if(q > 0)
		return 1;
	if(r > 0)
		return 0;
	return -1;
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t;
	cin >> t;
	
	while(t--) {
		wczytaj();
		int r = jebaj();
		if(r == 0)
			cout << "REMIS\n";
		else
			cout << (r > 0 ? "WYGRANA" : "PRZEGRANA") << "\n";
	}
}