#include <iostream>
#include <cmath>
using namespace std;
int t;
int n;
int m;
int pot;
bool tab1[100000];
bool tab2[100000];
int a;
int b;
char z;
int t1;
int t2;
bool warunek;
void test(){
    cin >> n;
    cin >> m;
    pot = pow(n, 2);
    if(m < n){
        cout << "REMIS" << endl;
    }
    else{
        for(int j = 0; j < m; j++){
            cin >> a;
            cin >> z;
            cin >> b;
            if(z == 62 && tab1[a - 1] == false){
                tab1[a - 1] = true;
                t1++;
            }
            else if(z == 62 && tab1[a - 1] == true){
                warunek = true;
            }
            else if(z == 60 && tab2[b - 1] == false){
                tab2[b - 1] = true;
                t2++;
            }
        }
        if(m == pot && pot != 1 && t1 == n && t2 == n){
            cout << "PRZEGRANA" << endl;
        }
        else if(t1 == n && t2 == n){
            if(warunek = true){
                cout << "WYGRANA" << endl;
            }
            else{
                cout << "REMIS" << endl;
            }
        }
        else if(t1 == n){
            if(warunek = true){
                cout << "WYGRANA" << endl;
            }
            else{
                cout << "REMIS" << endl;
            }
        }
        else if(t2 == n){
            cout << "PRZEGRANA" << endl;
        }
        else{
            cout << "REMIS" << endl;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> t;
    for(int i = 0; i < t; i++){
        test();
        for(int czys = 0; czys < 100000; czys++){
            tab1[czys] = false;
            tab2[czys] = false;
            t1 = 0;
            t2 = 0;
            warunek = false;
        }
    }
    return 0;
}
        | 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <iostream> #include <cmath> using namespace std; int t; int n; int m; int pot; bool tab1[100000]; bool tab2[100000]; int a; int b; char z; int t1; int t2; bool warunek; void test(){ cin >> n; cin >> m; pot = pow(n, 2); if(m < n){ cout << "REMIS" << endl; } else{ for(int j = 0; j < m; j++){ cin >> a; cin >> z; cin >> b; if(z == 62 && tab1[a - 1] == false){ tab1[a - 1] = true; t1++; } else if(z == 62 && tab1[a - 1] == true){ warunek = true; } else if(z == 60 && tab2[b - 1] == false){ tab2[b - 1] = true; t2++; } } if(m == pot && pot != 1 && t1 == n && t2 == n){ cout << "PRZEGRANA" << endl; } else if(t1 == n && t2 == n){ if(warunek = true){ cout << "WYGRANA" << endl; } else{ cout << "REMIS" << endl; } } else if(t1 == n){ if(warunek = true){ cout << "WYGRANA" << endl; } else{ cout << "REMIS" << endl; } } else if(t2 == n){ cout << "PRZEGRANA" << endl; } else{ cout << "REMIS" << endl; } } } int main() { ios_base::sync_with_stdio(false); cin >> t; for(int i = 0; i < t; i++){ test(); for(int czys = 0; czys < 100000; czys++){ tab1[czys] = false; tab2[czys] = false; t1 = 0; t2 = 0; warunek = false; } } return 0; } | 
 
            
         English
                    English