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
#include<bits/stdc++.h>
using namespace std;

int n,t[1000006],l1;
string s;

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')l1++;
    }
     l1-=3*n;
    if(l1>3*n||l1<0){
        cout<<"NIE";
        return 0;
    }
        for(int i=1;i<=n;i++){
            if(l1==0)cout<<"a";
            else if(l1>=3){
                cout<<"w";
                l1-=3;
            }
            else if(l1==2){
                cout<<"g";
                l1-=2;
            }
            else if(l1==1){
                cout<<"c";
                l1-=1;
            }
        }
        if(l1!=0){cout<<"NIE";return 0;}
}