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

const int R = 1e5 + 1;

int wcho[R], wych[R];

int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		int n, m;
		scanf("%d%d",&n,&m);
		while(m--){
			int a, b;
			char w;
			scanf("%d %c%d",&a,&w,&b);
			if(w == '<')wych[b]++;else wcho[b]++;
		}
		bool rown = false, row0 = false;
		for(int i=1;i<=n;i++){
			if(wcho[i] == n)rown = true;
			if(wych[i] == 0)row0 = true;
			wcho[i] = 0;
			wych[i] = 0;
		}
		if(rown)puts("WYGRANA");else
		if(row0)puts("REMIS");else
		puts("PRZEGRANA");
	}
	return 0;
}