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
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int t, n, m;
int vin[100004], vout[100004];

int main() {
    scanf("%d", &t);
    for (int cas = 0; cas < t; cas++) {
        scanf("%d%d", &n, &m);
        for (int i = 1; i <= n; i++) {
            vin[i] = vout[i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int a, b;
            char c[2];
            scanf("%d%s%d", &a, c, &b);
            if (c[0] == '<') {
                vout[b]++;
            } else {
                vin[b]++;
            }
        }
        int maxin = 0, numout = 0;
        for (int i = 1; i <= n; i++) {
            maxin = max(maxin, vin[i]);
            numout += vout[i] ? 1 : 0;
        }
        if (maxin == n) {
            printf("WYGRANA\n");
        } else 
        if (numout == n) {
            printf("PRZEGRANA\n");
        } else {
            printf("REMIS\n");
        }

    }
    return 0;
}