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 <iostream>
#include <vector>

using namespace std;

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int T;
	cin >> T;

	while (T--) {
		int k, m;
		cin >> k >> m;

		vector<int> pA(k + 1, 0), wA(k + 1, 0);
		while (m--) {
			int a, b;
			char w;
			cin >> a >> w >> b;

			if (w == '>') ++pA[b];
			else ++wA[b];
		}

		bool all_win = true;
		for (int i = 1; i < wA.size(); ++i) {
			if (wA[i] == 0) {
				all_win = false;
				break;
			}
		}

		if (all_win) {
			cout << "PRZEGRANA\n";
			goto END;
		}

		for (int i = 1; i < pA.size(); ++i) {
			if (pA[i] == k) {
				cout << "WYGRANA\n";
				goto END;
			}
		}

		cout << "REMIS\n";
END:
		;
	}

	return 0;
}