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
78
79
80
81
82
83
84
#include <bits/stdc++.h>
using namespace std;

#define fo(i, n) for(int i=0; i<n; i++)
#define FO(i, k, n) for(int i=k;i<n;i++)
#define chck(x) cout<<#x<<" "<<x<<"\n";
template<typename... T>
void read(T&... args){
    ((cin >> args), ...);
}

void ff(){
    cout << "NIE\n";
    exit(0);
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    int n;
    int ones = 0;
    int l;
    char temp;

    cin >> n;
    l = 8*n;

    char str[n+7];

    for(int i = 1; i <= l; i++){
        cin >> temp;
        if(temp=='1') ones++;
    }


    //cout << ones << "\n";

    fill(str+1, str+n+1, 'a');
    ones -= n*3;


    //cout << ones << "\n";

    if(ones<0) ff();

    int j = 1;
    for(int x = 3; x >= 1; x--){
        while(ones >= x && j <= n){
            str[j] = char(97+x);
            ones-=x;
            j++;
        }

        //cout << x << " " << ones << " " << j << "\n";
    }

    if(ones) ff();

    for(int i = 1; i <= n; i++){

        switch (int(str[i]))
        {
        case int('a'):
            cout << 'a';
            break;
        
        case int('b'):
            cout << 'c';
            break;
        
        case int('c'):
            cout << 'g';
            break;

        case int('d'):
            cout << 'o';
            break;
        }
    }
}