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

const int maxn = 100005;

int d[maxn];

int main() {

    set<int> s;
    char w[5];
    int t, n, m, a, b;

    scanf("%d", &t);

    while(t--) {

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

        while(m--) {

            scanf("%d%s%d", &a, w, &b);

            if(w[0] == '>')
                d[b]++;
            else s.insert(b);
        }

        int k = 0;

        for(int i = 1; i <= n; ++i) {

            k = max(k, d[i]);
        }

        if(s.size() >= n)
            printf("PRZEGRANA\n");
        else if(k >= n)
            printf("WYGRANA\n");
        else printf("REMIS\n");

        for(int i = 0; i <= n; ++i)
            d[i] = 0;

        s.clear();
    }
}