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

char let[] = {'a','c','g','o'};

void fail() {
	cout<<"NIE\n";
	exit(0);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	int cnt = 0;
	for(int i=0; i<8*n; ++i) {
		if(s[i] == '1') cnt++;
	}
	cnt -= 3 * n;
	if(cnt < 0) fail();
	string ans = "";
	for(int i=0; i<n; ++i) {
		int x = min(cnt, 3);
		ans += let[x];
		cnt -= x;
	}
	if(cnt > 0) fail();
	cout<<ans<<'\n';
}