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
#include<cstdio>

bool k1[100005];
bool k2[100005];

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		int n, m;
		scanf("%d%d", &n, &m);
		for (int i=1; i<=n; i++) k1[i] = k2[i] = 0;
		for (int i=0; i<m; i++)
		{
			int a, b; char c;
			scanf("%d %c %d", &a, &c, &b);
			if (c == '<') k2[b] = 1;
			else k1[a] = 1;
		}
		int t1=0, t2=0;
		for (int i=1; i<=n; i++) t1 += k1[i], t2 += k2[i];
		if (t1 > t2) printf(t1 == n ? "WYGRANA\n" : "REMIS\n");
		else printf("PRZEGRANA\n");
	}
	return 0;
}