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 <bits/stdc++.h>

using namespace std;

int t, n, m, a, b;
int lel[ 100007 ], fff[ 1000007 ];
char c;

int main()
{
	ios_base::sync_with_stdio( 0 );

		cin >> t;

		for( int z = 0; z < t; z++ )
		{
			cin >> n >> m;

			for( int i = 0; i < m; i++ )
			{
				cin >> a >> c >> b;

				if( c == '>' )
					lel[ b ]++;
				else
					fff[ b ]++;
			}
		bool win = 0;
		int lol = 0;

			for( int i = 1; i <= n; i++ )
			{
				if( lel[ i ] == n )
					win = 1;

				if( fff[ i ] )
					lol++;

				fff[ i ] = 0;
				lel[ i ] = 0;
			}

			if( win )
				cout << "WYGRANA" << endl;
			else if( lol == n )
				cout << "PRZEGRANA" << endl;
			else
				cout << "REMIS" << endl;
		}
}