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
import java.util.Scanner;
import java.util.regex.Pattern;

public class kar {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		for(int it=0;it<t;it++) {
			int n = in.nextInt();
			int m = in.nextInt();
			int[] player1 = new int[n];
			int[] player2 = new int[n];
			for(int i=0;i<m;i++) {
				int a = in.nextInt();
				char w = in.next(Pattern.compile(".")).charAt(0);
				int b = in.nextInt();
				if(w == '>')
					player1[b-1]++;
				else
					player2[b-1]++;
			}
			boolean isOver = false;
			for(int i=0;i<n;i++)
				if(player1[i]==n) {
					isOver = true;
				}
			if(isOver)
				System.out.println("WYGRANA");
			else {
				isOver=true;
				for(int i=0;i<n;i++) 
					if(player2[i]==0) {
						isOver = false;
						break;
					}
				if(isOver)
					System.out.println("PRZEGRANA");
				else
					System.out.println("REMIS");
			}
		}
	}
}