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
#include <stdio.h>
#include <string.h>

int main(void)
{
	int t, i;
	scanf("%d", &t);
	for (i = 0; i < t; i++)
	{
		int n, m;
		scanf("%d %d", &n, &m);
		int j, tab[4][100000];
		memset(tab, 0, sizeof(int)*4*100000);
		for (j = 0; j < m; j++)
		{
			int x, y; char c;
			scanf("%d %c %d", &x, &c, &y);
			char d = (c == '>' ? 0 : 1);
			tab[d][x-1]++;    /* >0 <1 */
			tab[2+!d][y-1]++; /* >3 <2 */
		}
		char winsuf = 0, losesuf = 0;
		int losers = 0, winners = 0;
		for (j = 0; j < n; j++)
		{
			if (tab[3][j] == n) /* >| */
				winsuf = 1;
			if (tab[1][j] == n) /* |< */
				losesuf = 1;
			if (tab[0][j] == 0) /* |> */
				losers++;
			if (tab[2][j] == 0) /* <| */
				winners++;
		}
		if (!winsuf && !losesuf)
		{
			if (losers && winners)
			{
				printf("REMIS\n");
			}
			else if (!losers)
			{
				if (winners < n)
					printf("WYGRANA\n");
				else printf("REMIS\n");
			}
			else printf("PRZEGRANA\n");
		}
		else if (winsuf)
			printf("WYGRANA\n");
		else printf("PRZEGRANA\n");
	}
	return 0;
}