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
#include <iostream>
using namespace std;

int n, l;
string s, wyn;

char c(int x) {
	if (x == 3) return 'a';
	else if (x == 4) return 'c';
	else if (x == 5) return 'z';
	else return 'o';
}

void f(int x, int y, int l1, int l2, string w, int k) {
	if (x - l1 >= 0 && y-l2 >=0) {
		k++;
		w += c(l1);
		if (k == n) {
			wyn = w;
			return;
		}
		for (int i = min(l1, x); i > 2; i--)
			f(x - l1, y-l2, i, 8-i, w, k);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> s;

	for (int i = 0; i < 8 * n; i++)
		if (s[i] == '1') l++;

	//cout << l << " "<< 8 * n - l << "\n";
	
	for (int i = 6; i > 2; i--) {
		f(l, 8*n-l, i, 8-i, "", 0);
		if (wyn.size()) break;
	}
	if (!wyn.size()) cout << "NIE";
	else cout << wyn;

}