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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>

using namespace std;

bool B[100000];
int A[100000];


int main()
{
  std::ios_base::sync_with_stdio(false);

  int testCount;
  int n, m;
  int a, b;
  char relation;
  int bCounter;

  cin >> testCount;

  while(testCount--)
  {
    cin >> n >> m;
    string result = "REMIS\n";
    bCounter = 0;

    for(int i = 0; i < n; i++)
    {
      A[i] = 0;
      B[i] = false;
    }

    for(int i = 0; i < m; i++)
    {
      cin >> a >> relation >> b;
      a--;
      b--;

      if(relation == '>')
      {
        A[b]++;
        if(A[b] == n)
        {
          result = "WYGRANA\n";
        }
      }
      else
      {
        if(B[b] == false)
        {
          B[b] = true;
          bCounter++;
          if(bCounter == n)
          {
            result = "PRZEGRANA\n";
          }
        }
      }

    }

    cout << result;
  }


   return 0;
}