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>

using namespace std;

int t;
int n, m;
int a, e;
int baj_ile[20], bit_ile[20];
bool bit[20][100000];
int baj[20][100000];
char z;

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

    for(int j=0; j<t; j++)
    {
        cin>>n>>m;
        for(int i=0; i<m; i++)
        {
            cin>>a>>z>>e;

            if((int)z == (int)'>')
            {
                    baj[j][e] ++;
                    if(baj_ile[j] < baj[j][e])
                        baj_ile[j] = baj[j][e];
            }
            else
            {
                if(!bit[j][e])
                {
                    bit_ile[j]++;
                    bit[j][e] = true;
                }
            }
        }
	
        if(bit_ile[j] == n)
            cout<<"PRZEGRANA\n";
        else if(baj_ile[j] == n)
            cout<<"WYGRANA\n";
        else
            cout<<"REMIS\n";

    }

    return 0;
}