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
#include <bits/stdc++.h>
using namespace std;
#define nd second
#define st first
#define pii pair<int,int>
#define pb push_back
typedef long long ll;


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

    int n;
    cin>>n;
    int cnt1=0;
    for(int i=0; i<8*n; i++){
        char c; cin>>c;
        if(c=='1') cnt1++;
    }
    if(cnt1<3*n || 6*n<cnt1){
        cout<<"NIE";
        return 0;
    }


    while(cnt1){
        int left=cnt1-3*n;
        int cur=3+min(left,3);

        if(cur==3) cout<<'a';
        else if(cur==4) cout<<'c';
        else if(cur==5) cout<<'g';
        else cout<<'o';
        
        cnt1-=cur;
        n--;
    }
}