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
#include <iostream>
#include <algorithm>
using namespace std;

int tA[1100000];
int tB[1100000];
int main(){
    int t,n,m;
    int a,b;
    char c;
    cin>>t;
    n = 0;
    while(t--){
        for(int i =1;i<=n;i++){tA[i]=0;tB[i]=0;}
        scanf("%d%d\n",&n,&m);
        while(m--){
            scanf("%d %c %d\n",&a,&c,&b);
            if(c=='>')
                tA[b]++;
            else
                tB[b]++;
        }
        int ile=0;
        bool ok = true;
        for(int i =1;i<=n;i++){
            if(tA[i] == n){
                cout<<"WYGRANA\n";
                ok=false;
                break;
            }
            if(tB[i]>0)
                ile++;
        }
        if(ok){
            if(ile==n){
                cout<<"PRZEGRANA\n";
            }else{
                cout<<"REMIS\n";
            }
        }
        
    }

    return 0;
}