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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <bits/stdc++.h>

#define double long double
#define LL long long
#define MP make_pair
#define ST first
#define ND second
#define PII pair<LL,LL >
#define PPIII pair<PII,int>
#define PPIIPII pair<PII,PII>
#define PIB pair<int,bool>
#define PIS pair<int,string>
#define PB push_back
#define VI vector<LL>
#define VVI vector<VI>
#define VLL vector<long long>
#define VVLL vector<VLL>
#define VB vector<bool>
#define VPII vector<PII>
#define VPPIII vector<PPIII>
#define VPPIIPII vector<PPIIPII>
#define VPIB vector<PIB>
#define VPIS vector<PIS>
#define SI set<int>
#define SPII set<PPIII>
#define VS vector<string>
#define PB push_back
#define INF (LL) 1000000000000
#define MOD 2000007
#define ALL(c) c.begin(),c.end()
#define NWD __gcd
#define SIZE 1000000

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int t;
    cin>>t;

	while(t--)
	{
		int n, m;
		cin>>n>>m;
		VI v;
		v.resize(n);
		VI v2;
		v2.resize(n);
		for(int i=0;i<m;i++)
		{
			int a, b;
			char c;
			cin>>a>>c>>b;
			a--, b--;
			if(c=='>')
				v[b]++;
			else
				v2[b] = 1;
		}

		bool f=false;
		for(int i=0;i<n;i++)
		{
			if(v[i] == n)
			{
				f=true;
				cout<<"WYGRANA"<<endl;
				break;
			}
		}
		if(!f)
		for(int i=0;i<n;i++)
		{
			if(v2[i] == 0)
			{
				f=true;
				cout<<"REMIS"<<endl;
				break;
			}
		}
		if(!f)
			cout<<"PRZEGRANA"<<endl;

	}

	return 0;

}