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
54
55
56
57
58
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int n;
string word;
int ones=0;
char tab[7] = {' ', ' ', ' ', 'a', 'c', 'g', 'w'};
int min_ones, max_ones;

void count_ones(){
	for(int i=0;i<8*n;++i){
		if(word[i]=='1'){
			ones++;
		}
	}
}

void generate_string(){
	int min_tab[n+1];
	int missing_ones = ones - min_ones;

	for(int i=0;i<n;++i){
		min_tab[i]=3;
		if(missing_ones > 3){
			min_tab[i] += 3;
			missing_ones -= 3;
		}else{
			min_tab[i] += missing_ones;
			missing_ones = 0;
		}
	}
	for(int i=0;i<n;++i){
		printf("%c",tab[min_tab[i]]);
	}
	printf("\n");
}

int main(){
	scanf("%d", &n);
	cin>>word;
	count_ones();
	min_ones = 3*n;
	max_ones = 6*n;
	
	if(ones < min_ones || ones > max_ones){
		printf("NIE\n");
	}else{
		generate_string();
	}
	// printf("%d\n", ones);
	return 0;
}