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
59
60
61
62
63
64
65
66
67
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<long long>(a, b)(rng)

#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define f first
#define s second
#define pb push_back

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>

#define ll long long

const int N = 1e6 + 7;

void solve(){
    int n; cin >> n;

    map<int, char> mapa;
    for(int i = 0; i < 26; i++){
        int ile = __builtin_popcount(97 + i);
        if(mapa.count(ile) == 0)
            mapa[ile] = 'a' + i;
    }

    string s;
    cin >> s;

    int ile = 0;
    for(auto & u : s)
        ile += u == '1';

    if(ile < n * 3 or ile > n * 6){
        cout << "NIE\n";
        return;
    }

    for(int i = 6; i >= 3; i--)
        while(n and (n - 1) * 3 <= ile - i){
            cout << mapa[i];
            ile -= i;
            n--;
        }

    cout << '\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int tests = 1;
    // cin >> tests;

    for(int i = 0; i < tests; i++)
        solve();

    return 0;
}