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
47
48
49
50
51
52
53
54
#include <algorithm>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

unsigned constexpr N = 1e5 + 10;

signed char enemyChoice(unsigned const n, vector<signed char> const & adj) {
    signed char mini = 0;
    if(adj.size() == n)
        mini = 1;
    for(auto const & w : adj)
        mini = min(mini, w);
    return mini;
}

void testCase() {
    vector<signed char> adj[N];
    unsigned n, m;

    scanf("%u%u", &n, &m);

    while(m--) {
        unsigned a, b;
        char w;
        scanf("%u %c%u", &a, &w, &b);
        adj[b].emplace_back(w == '>' ? 1 : -1);
    }


    signed char maxi = -1;
    for(unsigned enemy = 1 ; enemy <= n ; ++enemy)
        maxi = max(maxi, enemyChoice(n, move(adj[enemy])));

    switch(maxi) {
    case 1:
        printf("WYGRANA\n");
        break;
    case 0:
        printf("REMIS\n");
        break;
    case -1:
        printf("PRZEGRANA\n");
        break;
    }
}

int main() {
    unsigned char t;
    scanf("%hhu", &t);
    while(t--)
        testCase();
}