#include <cstdio>
#include <vector>
using namespace std;
void Solve() {
  int n;
  int m;
  scanf("%d %d\n", &n, &m);
  vector<int> b_more(n), b_less(n);
  while (m--) {
    int a;
    char w;
    int b;
    scanf("%d %c %d\n", &a, &w, &b);
    --b;
    if (w == '>') ++b_more[b]; else ++b_less[b];
  }
  for (int i = 0; i < n; ++i) {
    if (b_more[i] == n) {
      printf("WYGRANA\n");
      return;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (b_less[i] == 0) {
      printf("REMIS\n");
      return;
    }
  }
  printf("PRZEGRANA\n");
}
int main() {
  int t;
  scanf("%d\n", &t);
  while (t--) Solve();
  return 0;
}
        | 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 | #include <cstdio> #include <vector> using namespace std; void Solve() { int n; int m; scanf("%d %d\n", &n, &m); vector<int> b_more(n), b_less(n); while (m--) { int a; char w; int b; scanf("%d %c %d\n", &a, &w, &b); --b; if (w == '>') ++b_more[b]; else ++b_less[b]; } for (int i = 0; i < n; ++i) { if (b_more[i] == n) { printf("WYGRANA\n"); return; } } for (int i = 0; i < n; ++i) { if (b_less[i] == 0) { printf("REMIS\n"); return; } } printf("PRZEGRANA\n"); } int main() { int t; scanf("%d\n", &t); while (t--) Solve(); return 0; } | 
 
            
         English
                    English