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

const int N = 100000;
int czy1[N + 1], czy2[N + 1], czy3[N + 1];
int tura = 0;

int main()
{
	ios_base::sync_with_stdio(0);
    int t;
    cin >> t;

    for(int i = 0; i < t; ++i){
        int n, m, win = 0, lose = 0, licznik = 0; tura++;
        cin >> n >> m;

        for(int j = 0; j < m; ++j){
            int a, b; char znak;
            cin >> a >> znak >> b;
            if(znak == '>'){
                if(czy1[a] != tura){
                    ++win;
                    czy1[a] = tura;
                }
            }
            else{
                if(czy2[b] != tura){
                    ++lose;
                    czy2[b] = tura;
                }
            }
        }

        if(lose == n) cout << "PRZEGRANA\n";
        else if(win == n) cout << "WYGRANA\n";
        else cout << "REMIS\n";
    }

    return 0;
}