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
#include<bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	string s;
	cin >> n >> s;

	int ones = 0;
	for(char c : s)
		if(c == '1') ones++;

	ones -= 3*n;
	string res(n,'a');
	for(int i=0;i<n && ones > 0;i++,ones--)
		res[i] = 'c';
	for(int i=0;i<n && ones > 0;i++,ones--)
		res[i] = 'g';
	for(int i=0;i<n && ones > 0;i++,ones--)
		res[i] = 'o';

	cout << (ones == 0 ? res : "NIE") << "\n";

	return 0;
}