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
#include <bits/stdc++.h>

const int N = 100000;
int cnta[N], cntb[N];

int main() {
  int t; scanf("%d", &t);
  for (int cas = 1; cas <= t; ++cas) {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
      cnta[i] = cntb[i] = 0;
    }
    for (int i = 0; i < m; ++i) {
      int a, b;
      char w[10];
      scanf("%d%s%d", &a, w, &b);
      if (w[0] == '>') cnta[b]++;
      else cntb[b]++;
    }
    bool win = false, lost = true;
    for (int i = 1; i <= n; ++i) {
      if (cnta[i] == n) win = true;
      if (cntb[i] == 0) lost = false;
    }
    if (win) puts("WYGRANA");
    else if (lost) puts("PRZEGRANA");
    else puts("REMIS");
  }
  return 0;
}