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


using namespace std;


map <int,char> cntToChar;


string solve(int n, const string &s) {
    int cnt[2] = {0, 0};
    for (char c : s) {
        cnt[c - '0']++;
    }

    if (cnt[1] < 3 * n || cnt[1] > 6 * n) {
        return "NIE";
    }

    vector <int> cnts(n, cnt[1] / n);

    int rem = cnt[1] % n;
    for (int i = 0; i < rem; i++) {
        cnts[i]++;
    }

    string res;
    for (int i = 0; i < n; i++) {
        res.push_back(cntToChar[cnts[i]]);
    }

    return res;
}

void prepare() {
    for (char c = 'a'; c <= 'z'; c++) {
        cntToChar[__builtin_popcount(c)] = c;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    prepare();

    int n;
    cin >> n;

    string s;
    cin >> s;

    cout << solve(n, s);

    return 0;
}