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

// #define DEBUG_M
#ifdef DEBUG_M
#define DEBUGF(...) printf(stderr, __VA_ARGS__)
#define DEBUG(expr) expr
#else
#define DEBUGF(...)
#define DEBUG(expr)
#endif

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	string str;
	cin >> str;
	int count1 = 0;
	for (size_t i = 0; i < str.size(); i++) {
		count1 += str[i] - '0';
	}
	// int count0 = n*8 - count1;
	if (count1 < 3*n || count1 > 6*n) {
		puts("NIE");
		return 0;
	}
	count1 -= n*3;
	string out(n, 'a');
	for (int i = 0, add = 2; i < count1;) {
		for (int j = 0; i < count1 && j < n; j++) {
			out[j] += add;
			i++;	
		}
		add <<= 1;
	}

	puts(out.c_str());
}