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
//	Michał Wiatrowski

#include <iostream>
#include <vector>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	for (int test_case = 1; test_case <= t; ++test_case) {
		int n, m;
		cin >> n >> m;
	
		vector<int> bitek_losses(n, 0);
		vector<int> bitek_wins(n, 0);

		for (int i = 0; i < m; ++i) {
			int a, b;
			char w;
			cin >> a >> w >> b;
			a--; b--;

			if (w == '<')
				bitek_losses[b] += 1;
			else
				bitek_wins[b] += 1;
		}

		{
			bool win = false;
			for (int i = 0; i < n; ++i)
				if (bitek_wins[i] == n) {
					win = true;
					break;
				}
			if (win) {
				cout << "WYGRANA" << endl;
				continue;
			}
		}
		{
			bool loss = true;
			for (int i = 0; i < n; ++i)
				if (bitek_losses[i] == 0) {
					loss = false;
					break;
				}
			if (loss) {
				cout << "PRZEGRANA" << endl;
				continue;
			}
		}
		cout << "REMIS" << endl;
	}
}