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

int main() {
    int z;
    scanf ("%d" , &z);

    while(z--) {
        int n,m;
        scanf ("%d %d", &n, &m);
    
        vector<int> a,b;
        a.resize(n,0);
        b.resize(n,0);
        
        // 0 - draw; 1-loss; 2-win
        int result = 0;
        while(m--) {
           int q,w;
           char c;
           
           scanf ("%d %c %d", &q, &c, &w);
           q--;
           w--;

           if (c == '<') {
               a[q]++;
               if (a[q] == n)
                   result = 1;
           } else {
               b[w]++;
               if (b[w] == n)
                   result = 2;
           }
        }

        if (result == 0)
            printf("REMIS\n");
        else if (result == 1)
            printf("PRZEGRANA\n");
        else
            printf("WYGRANA\n");
    }
    return 0;
}