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
#include <iostream>
using namespace std;

bool win(long W[], long n) {
	for (long i=0; i<n; i++)
		if (W[i]==n)
			return true;
	return false;
}

bool draw(long D[], long n) {
	for (long i=0; i<n; i++)
		if (D[i]==0)
			return true;
	return false;
}

int main() {
	int t;
	cin>>t;
	for (int j=0; j<t; j++) {
		long n;
		cin>>n;
		long *W=new long[n];
		for (long i=0; i<n; i++) W[i]=0;
		long *D=new long[n];
		for (long i=0; i<n; i++) D[i]=0;
		long m;
		cin>>m;
		for (long i=0; i<m; i++) {
			long a,b;
			char w;
			cin>>a;
			cin>>w;
			cin>>b;
			if (w=='<') D[b-1]++; else W[b-1]++;
		}
		if (win(W,n)) {
			cout<<"WYGRANA";
		} else if (draw(D,n)) {
			cout<<"REMIS";
		} else {
			cout<<"PRZEGRANA";
		}
		cout<<endl;
		delete D;
		delete W;
	}
	return 0;
}