#include<bits/stdc++.h>
using namespace std;
int tab[100009], tac[100009];
inline void solve()
{
	int n,m,a,b,s1=0,s2=0;
	char c;
	cin>>n>>m;
	for(int i=1; i<=n; i++) tab[i]=tac[i]=0;
	for(int i=1; i<=m; i++)
	{
		cin>>a>>c>>b;
		if(c=='>')
		{
			if(tab[a]==0)
			{
				tab[a]=1;
				s1++;
			}
		}
		else
		{
			if(tac[b]==0)
			{
				tac[b]=1;
				s2++;
			}
		}
	}
	if(s1==n)
	{
		if(s2<n) cout<<"WYGRANA\n";
		else cout<<"PRZEGRANA\n";
	}
	else
	{
		if(s2<n) cout<<"REMIS\n";
		else cout<<"PRZEGRANA\n";
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	int t;
	cin>>t;
	while(t--) solve();
	return 0;
}
        | 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 | #include<bits/stdc++.h> using namespace std; int tab[100009], tac[100009]; inline void solve() { int n,m,a,b,s1=0,s2=0; char c; cin>>n>>m; for(int i=1; i<=n; i++) tab[i]=tac[i]=0; for(int i=1; i<=m; i++) { cin>>a>>c>>b; if(c=='>') { if(tab[a]==0) { tab[a]=1; s1++; } } else { if(tac[b]==0) { tac[b]=1; s2++; } } } if(s1==n) { if(s2<n) cout<<"WYGRANA\n"; else cout<<"PRZEGRANA\n"; } else { if(s2<n) cout<<"REMIS\n"; else cout<<"PRZEGRANA\n"; } return; } int main() { ios_base::sync_with_stdio(false); int t; cin>>t; while(t--) solve(); return 0; } | 
 
            
         English
                    English