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
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, m, out[100010],  i[100010], w1, w2, x, y, rem;
int t;
char znak;
int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>t;
	while( t-- )
	{
		cin>>n>>m;
		for( int a = 1; a <= m; a++ )
		{
			cin>>x>>znak>>y;
			if( znak == '>' )i[y]++;
			else out[y] = 1;	
		}
		for( int a = 1; a <= n; a++ )
		{
			if( i[a] == n )w1 = 1;
			else if( out[a] )w2 = 1;
			else rem = 1;
		}	
		if( w1 )cout<<"WYGRANA"<<endl;
		else if( rem )cout<<"REMIS"<<endl;
		else cout<<"PRZEGRANA"<<endl;
		for( int a = 1; a <= n; a++ )i[a] = out[a] = 0;
		w1 = w2 = rem = 0;
	}
	return 0;
}