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
// Szymon Rusiecki (07.12.2021)
#include <bits/stdc++.h>

int main() {
	int n;
	std::cin >> n;

	int l_0 = 0;
	int l_1 = 0;

	for (int i = 0; i < 8 * n; ++i) {
		char x;
		std::cin >> x;
		if (x == '1')
			++l_1;
		else
			++l_0;
	}

	if (l_1 > l_0 + 4 * n) {
		std::cout << "NIE";
		return 0;
	}
	else if (l_0 > l_1 + 2 * n) {
		std::cout << "NIE";
		return 0;
	}
	
	for (int i = 0; i < n; ++i) {
		if (l_1 >= l_0 + 4) {
			l_1 -= 6;
			l_0 -= 2;
			std::cout << 'o';
		}
		else if (l_1 == l_0 + 2) {
			l_1 -= 5;
			l_0 -= 3;
			std::cout << 's';
		}
		else if (l_1 == l_0) {
			l_1 -= 4;
			l_0 -= 4;
			std::cout << 'r';
		}
		else {
			l_1 -= 3;
			l_0 -= 5;
			std::cout << 'a';
		}
	}

	return 0;
}