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 <bits/stdc++.h>
using namespace std;

const int N = 100 * 1000 + 5;

vector<int> win_rev[N];
vector<int> lose_rev[N];

char znak[20];

int main() {
    int t;
    scanf("%d", &t);
    while(t --) {
        int n, m;
        scanf("%d%d", &n, &m);
        for (int i = 1; i <= n; i ++) {
            win_rev[i].clear();
            lose_rev[i].clear();
        }
        for (int i = 0; i < m; i ++) {
            int a, b;
            scanf("%d%s%d", &a, znak, &b);
            if (znak[0] == '>') {
                win_rev[b].push_back(a);
            }
            else lose_rev[b].push_back(a);
        }
        bool WIN = false;
        bool DRAW = false;
        for (int i = 1; not WIN && i <= n; i ++) {
            if ((int)win_rev[i].size() == n) WIN = true;
            if (lose_rev[i].empty()) DRAW = true;
        }
        if (WIN) {
            printf("WYGRANA\n");
            continue;
        }
        if (DRAW) {
            printf("REMIS\n");
            continue;
        }
        printf("PRZEGRANA\n");
    }
}