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

using namespace std;

int main() {
	std::ios_base::sync_with_stdio(false);
	int n, ones = 0;
	cin >> n;
	for (int i = 0; i < 8 * n; i++) {
		char c;
		cin >> skipws >> c;
		ones += c == '1' ? 1 : 0;
	}
	if (ones < 3 * n || ones > 6 * n) {
		cout << "NIE" << endl;
		return 0;
	}
	ones -= 3 * n;
	while (ones >= 3) {
		cout << 'o';
		ones -= 3;
		n--;
	}
	if (ones == 2) {
		n--;
		cout << 'g';
	} else if (ones == 1) {
		n--;
		cout << 'c';
	}
	while (n > 0) {
		n--;
		cout << 'a';
	}
	cout << endl;
	return 0;
}