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

#define MAXN 100007

int right_in[MAXN], right_out[MAXN];

int main() {
    int t, n, m;

    scanf("%d", &t);
    while (t--) {
        scanf("%d %d ", &n, &m);
        for (int i = 1; i <= n; i++) {
            right_in[i] = 0;
            right_out[i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int a, b;
            char c;
            scanf("%d %c %d ", &a, &c, &b);
            if (c == '>')
                right_in[b]++;
            else
                right_out[b]++;
        }
        bool win = false, lose = true;
        for (int i = 1; i <= n; i++) {
            if (right_in[i] == n) {
                win = true;
            }
            if (right_out[i] == 0) {
                lose = false;
            }
        }

        if (win) 
            printf("WYGRANA\n");
        else if (lose)
            printf("PRZEGRANA\n");
        else
            printf("REMIS\n");
    }
    return 0;
}