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
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

#define MAX_N 100000

int F[MAX_N];
int maxF = 0;
bool S[MAX_N];
int countS = 0;

int main(){
    int t;
    scanf("%d", &t);
    while(t--){
        int n, m;
        scanf("%d%d", &n, &m);
        for(int a=0; a<m; ++a){
            int i, j;
            char c;
            scanf("%d %c %d", &i, &c, &j);
            --i; --j;
            if(c == '>'){
                maxF=max(maxF, ++F[j]);
            }else{
                if(!S[j]){
                    S[j] = 1;
                    ++countS;
                }
            }
        }
        if(maxF == n)printf("WYGRANA\n");
        else if(countS == n)printf("PRZEGRANA\n");
        else printf("REMIS\n");

        maxF = 0;
        countS = 0;
        memset(F, 0, n * sizeof(*F));
        memset(S, 0, n * sizeof(*S));
    }

    return 0;
}