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
#include<cstdio>
using namespace std;
const int C = 100006;
bool t[C], rt[C];
void solve() {
    int n, m;
    scanf("%d%d\n", &n, &m);
    char c;
    int a, b;
    for(int i = 0; i < m; i++) {
        scanf("%d %c %d\n", &a, &c, &b);
        if(c=='>') t[a] = 1;
        else rt[b] = 1;
    }
    bool t1 = 1, t2 = 1;
    for(int i = 1; i <= n; i++) {
        if(!t[i]) t1 = 0;
        if(!rt[i]) t2 = 0;
        t[i] = 0;
        rt[i] = 0;
    }
    if(!t1 and !t2) printf("REMIS\n");
    else if(!t1) printf("PRZEGRANA\n");
    else printf("WYGRANA\n");
}

int main() {
    int t;
    scanf("%d", &t);
    while(t--) solve();
}