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
// set::find
#include <iostream>

using namespace std;
int bajtek = 100001;

int main ()
{
    int t;
    cin>>t;
    while( t-- )
    {
        int n, m;
        cin>>n>>m;
        int tab[200006];
        for ( int i = 0; i <= n; i++ )
        {
            tab[i] = 0;
            tab[i + bajtek] = 0;
        }
        for ( int i = 0; i < m; i++)
        {
            int a, b;
            char ch;
            cin>>a>>ch>>b;
            if( ch == '>' )
            {
                tab[a]++;
            }
            else
            {
                tab[b + bajtek] ++;
            }
        }
        int sw1 = 0, sw2 = 0;
        for( int i = 1; i <= n; i++ )
        {
            if( tab[i] == 0 ) sw1 = 1;
            if ( tab[i + bajtek] == 0 ) sw2 = 1;
        }

        if ( sw1 == 1 && sw2 == 1 )
        {
            cout<<"REMIS"<<endl;
        }
        else if ( sw2 == 1 )
        {
            cout<<"WYGRANA"<<endl;
        }
        else
        {
            cout<<"PRZEGRANA"<<endl;
        }

    }

  return 0;
}