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
#include <iostream>
#include <vector>
using namespace std;

void rozwiaz()
{
    int n, m;
    cin >> n >> m;
    vector <int> T1;
    vector <bool> T2;
    T1.resize(n+1, 0);
    T2.resize(n+1, false);
    for (int i = 0; i < m; i++){
        int k, l;
        char c;
        cin >> k >> c >> l;
        if (c == '>')
            T1[l]++;
        else
            T2[l] = true;
    }
    bool lose = true;
    for (int i = 1; i <= n; i++)
        if (!T2[i]){
            lose = false;
            break;}
    if (lose) {
        cout << "PRZEGRANA" << endl;
        return;
    }
    bool win = false;
    for (int i = 1; i <= n; i++)
        if (T1[i] == n) {
            win = true;
            break;
        }
    if (win)
        cout << "WYGRANA" << endl;
    else
        cout << "REMIS" << endl;
    return;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++)
        rozwiaz();
    return 0;
}