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
#ifdef _MSC_VER
  #ifndef __GNUC__
    #pragma warning(disable: 4996)
  #endif
  #define main main0
#endif
#include <iostream>
#include <cstring>
using namespace std;

static const int MaxN = 100001;
int sukcess0[MaxN], sukcess1[MaxN];

int main() {
  ios_base::sync_with_stdio(0);
  //cin.tie(NULL);
  int t;
  cin >> t;
  do {
    int n, m, result0 = 0, result1 = 0;
    cin >> n >> m;
    memset(sukcess0, 0, (n + 1) * sizeof(int));
    memset(sukcess1, 0, (n + 1) * sizeof(int));
    do {
      int a, b;
      char rel;
      cin >> a >> rel >> b;
      if(rel == '>')
        ++sukcess0[a];
      else
        ++sukcess1[b];
    }while (--m > 0);
    for(int i = 1; i <= n; ++i) {
      if(sukcess0[i] > 0)
        ++result0;
      if(sukcess1[i] > 0)
        ++result1;
    }
    if(result0 >= n && result1 < n)
      cout << "WYGRANA\n";
    else if(result1 >= n && result0 < n)
      cout << "PRZEGRANA\n";
    else
      cout << "REMIS\n";
  } while(--t > 0);
  return 0;
}