#include<bits/stdc++.h>
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
using namespace std;
const int MXN = 1e5+5;
int cnt[2][MXN];
void solve()
  {
  int n, m;
  scanf("%d%d", &n, &m);
  FOR(i, 1, n)cnt[0][i] = cnt[1][i] = 0;
  FOR(i, 1, m)
    {
    int a, b;
    char ch;
    scanf("%d %c%d", &a, &ch, &b);
    cnt[ch == '<'][b]++;
    }
  FOR(i, 1, n)
    if(cnt[0][i] == n)  
      {
      puts("WYGRANA");
      return;
      }
  FOR(i, 1, n)
    if(cnt[1][i] == 0)  
      {
      puts("REMIS");
      return;
      }
  puts("PRZEGRANA");
  }
int main()
  {
  int z;
  scanf("%d", &z);
  while(z--)solve();
  }
        | 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 | #include<bits/stdc++.h> #define FOR(x, b, e) for(int x=b;x<=(e);x++) using namespace std; const int MXN = 1e5+5; int cnt[2][MXN]; void solve() { int n, m; scanf("%d%d", &n, &m); FOR(i, 1, n)cnt[0][i] = cnt[1][i] = 0; FOR(i, 1, m) { int a, b; char ch; scanf("%d %c%d", &a, &ch, &b); cnt[ch == '<'][b]++; } FOR(i, 1, n) if(cnt[0][i] == n) { puts("WYGRANA"); return; } FOR(i, 1, n) if(cnt[1][i] == 0) { puts("REMIS"); return; } puts("PRZEGRANA"); } int main() { int z; scanf("%d", &z); while(z--)solve(); } | 
 
            
         English
                    English