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;

#define MAXN 100001
#define pb push_back

int ile[MAXN];
int ile1[MAXN];
int tasks;
int n,m;
int xxx = 0;
void zeruj()
{
	for(int i = 1;i <= n;++i) ile[i] = ile1[i] = 0;
}
int xD()
{
	scanf("%d%d",&n,&m);
	for(int i = 0;i < m;++i)
	{
		int a,b; char zn;
		scanf("%d %c%d",&a,&zn,&b);

		if(zn == '>') ile[b]++;
		else ile1[b]++;
	}
	int g = 0;

	for(int i = 1;i <= n;++i)
	{
///		if(ile[i] != 1) printf("%d\n",ile[i]);
		if(ile[i] == n) {zeruj();return 2;}
		if(ile1[i] == 0) g = 1;
	}
	zeruj();
	return g;
}

int main()
{
	scanf("%d",&tasks);
	while(tasks--)
	{
		++xxx;
		int xd = xD();
		puts(xd == 1 ? "REMIS" : xd == 0 ? "PRZEGRANA" : "WYGRANA");
	}
}