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
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class kar {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = Integer.valueOf(sc.next());
        for(int i = 0; i< t; i ++){
            Set<Integer> player1Win = new HashSet<>();
            Set<Integer> player2Win = new HashSet<>();
            int n = Integer.valueOf(sc.next());
            int m = Integer.valueOf(sc.next());
            for(int j = 0; j < m; j++){
                int p1deck = Integer.valueOf(sc.next());
                char sign = sc.next().charAt(0);
                int p2deck = Integer.valueOf(sc.next());
                if('<' == sign){
                    player2Win.add(p2deck);
                } else {
                    player1Win.add(p1deck);
                }
            }
                if(player1Win.size() == n){
                    System.out.println("WYGRANA");
                } else if (player2Win.size() == n){
                    System.out.println("PRZEGRANA");
                } else {
                    System.out.println("REMIS");
                }
        }

    }

}