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 <algorithm>
#include <vector>
#include <set>

int main() {
	int c = 0;
	std::cin >> c;
	std::vector<int> vec;
	std::string in_return = "";
	for (int i = 0; i < c; i++) {
		// single test_case
		int deck = 0;
		int win = 0;
		std::cin >> deck >> win;
		std::vector<std::pair<int, std::pair<int, int>>> data;
		std::set<int> left;
		std::set<int> right;
		std::set<int> left_win;
		for (int j = 0; j < win; j++) {
			char c = '0';
			int op = 0;
			int l = 0;
			int r = 0;
			std::cin >> l >> c >> r;
			if (c == '<') {
				op = -1;
				right.insert(r);
			} else {
				op = 1;
				left.insert(l);
				left_win.insert(r);
			}
			data.push_back({op, {l, r}});
			//printf("%d %d %d\n", l, op, r);
		}
		int left_size = left.size();
		int right_size = right.size();
		if (right_size == deck) {
			in_return += "PRZEGRANA\n";
		} else if (right_size < deck) {
			if (left_size < deck) {
				in_return += "REMIS\n";
			} else if (left_size == deck) {
				if (left_win.size() == 1) {
					in_return += "WYGRANA\n";
				} else {
					in_return += "REMIS\n";
				}
			}
		}
	}
	std::cout << in_return;
}