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

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

	int ones = 0;
	for (int i = 0; i < 8*n; ++i) {
		char a;
		std::cin >> a;

		ones += (a == '1');
	}

	ones -= 2*n;
	if (ones < n || ones > 4*n) {
		std::cout << "NIE" << std::endl;
		return 0;
	}

	char chars[5] = { 'x', 'a', 'c', 'g', 'o' };
	int lower = ones / n;
	int highers = ones % n;
	for (int j = 0; j < n; ++j)
		std::cout << chars[lower + (j < highers)];
	std::cout << std::endl;

	return 0;
}