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
//Hanczar

#include <cstdio>
#include <vector>
#include <array>

struct values {
  int bit_los;
  int bit_win;
};

int main() {
  int t;
  scanf("%d",&t);
  while(t--) {
    int n,m;
    scanf("%d %d",&n,&m);
    std::vector<values> vals(n);
    for (int i=0;i<m;++i) {
      int a,b;
      char cnd;

      scanf("%d %c %d",&a,&cnd,&b);
      if (cnd=='<') {
        ++vals[b-1].bit_win;
      } else {
        ++vals[b-1].bit_los;
      }
    }

    int bit_winning = 0;
    int i;
    for (i=0;i<n;i++) {
      auto &v = vals[i];
      if (v.bit_win) {
        ++bit_winning;
      }
      if (v.bit_los == n) {
        puts("WYGRANA");
        break;
      }
    }
    if (i==n) {
      if (bit_winning == n) {
        puts("PRZEGRANA");
      } else {
        puts("REMIS");
      }
    }
  }
  return 0;
}