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
// Piotr Golda

#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

unsigned int T, N, M;

int main()
{
	unsigned int a, b;
	char c;

	scanf("%ud", &T);
	for (unsigned int t = 0; t < T; ++t)
	{
		scanf("%ud", &N);
		scanf("%ud", &M);
		vector<unsigned int> Baj;
		vector<unsigned int> Bit;
		Baj.resize(N, 0);
		Bit.resize(N, 0);

		for (unsigned int i = 0; i < M; ++i)
		{
			scanf("%u %c %u", &a, &c, &b);
			if (c == '>')
			{
				Baj[b-1]++;
			}
			else
			{
				Bit[b-1]++;
			}
		}
		bool finish = false;
		for (auto sum : Baj)
		{
			if (sum == N)
			{
				printf("WYGRANA\n");
				finish = true;
				break;
			}
		}
		if (finish)
			continue;
		for (auto sum : Bit)
		{
			if (sum == 0)
			{
				printf("REMIS\n");
				finish = true;
				break;
			}
		}
		if (finish)
			continue;
		printf("PRZEGRANA\n");

	}
	
	return 0;
}