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
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>
#include <random>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,int>
#define mp make_pair
#define pll pair<long long,long long>
#define ld long double
#define ull unsigned long long

using namespace std;



void solve(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> v;
    for(char i='a';i<='z';i++){
        int cur = int(i);
        v.pb(cur);
    }
    vector<string> opcje;
    for(int c : v){
        vector<char> xd;
        int tmp = c;
        for(int i=0;i<8;i++){
            xd.pb('0' + tmp % 2);
            tmp /= 2;
        }
        reverse(xd.begin(), xd.end());
        string cur = "";
        for(char x : xd) cur += x;
        opcje.pb(cur);
    }

    int ile = 0;
    for(char x : s){
        if(x == '1') ile += 1;
    }
    if(ile < n * 3 || ile > n * 6){
        cout << "NIE" << "\n";
        return;
    }
    int zaDuzo = ile - n * 3;
    vector<char> ans;
    for(int i=0;i<n;i++){
        int teraz = 3;
        int biore = min(zaDuzo, 3);
        zaDuzo -= biore;
        teraz += biore;
        for(int j=0;j<26;j++){
            int h = 0;
            for(auto x : opcje[j]){
                h += (x == '1');
            }
            if(h == teraz){
                ans.pb('a' + j);
                break;
            }
        }
    }
    for(auto x : ans) cout << x;

}

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

    int tt = 1;
    // cin >> tt;
    while(tt--) solve();

    return 0;
}