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

int main() {
  ios::sync_with_stdio(false);
  int z; cin >> z;
  while (z--) {
    int n, m; cin >> n >> m;
    vector<bool> win(n, false);
    vector<int> nlose(n, 0);
    for (int i = 0; i < m; ++i) {
      int a, b; char w;
      cin >> a >> w >> b;
      if (w == '>')
        ++nlose[b-1];
      else
        win[b-1] = true;
    }
    if (accumulate(win.begin(), win.end(), 0) == n)
      cout << "PRZEGRANA\n";
    else if (find(nlose.begin(), nlose.end(), n) != nlose.end())
      cout << "WYGRANA\n";
    else
      cout << "REMIS\n";
  }
  return 0;
}