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
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int j = 0;
    int x = 0;
    
    string ans = "";
    
    for(int i=0; i<8*n; i++){
        if(s[i]=='1'){
            j++;
        }
    }
    
    bool f = true;
    
    if(j==0){
        cout << "NIE\n";
        f = false;
    }else if(j>=4 && j%3==1){
        ans += 'c';
        j-=4;
        x+=1;
    }else if(j>=5 && j%3==2){
        ans += 'g';
        j-=5;
        x+=1;
    }
    
    if(f){
        if(j%3==0){
            if(6*(n-x)<j){
                cout << "NIE\n";
            }else if(3*(n-x)>j){
                cout << "NIE\n";
            }else{
                while(3*(n-x) != j){
                    ans += 'o';
                    j -=6;
                    x +=1;
                }
                while(j!=0){
                    ans += 'a';
                    j -=3;
                    x +=1;
                }
                cout << ans << "\n";
            }
        }else{
            cout << "NIE\n";
        }
    }
    return 0;
}