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

using namespace std;
#define FOR(n, u) for(int (n) = 0; (n) < (u); n++)


int main(){
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    float n; int x;
    string ciag;
    cin >> n;
    cin >> ciag;
    int il_0 = 0, il_1 = 0;
    FOR(i, ciag.size()){
        x = ciag[i] - '0';
        if(x == 0)
            il_0++;
        else
            il_1++;
    }
    //cout << "x";
    if(il_1 / n < 3 || il_1 / n > 6 || il_0 / n < 2 || il_0 / n > 5){
        cout << "NIE";
        return 0;
    }
    string napis;
 //   cout << il_0 << endl;
    while(il_0 / n > 4.0){
        napis += 'a';
        il_0 -= 5;
        il_1 -= 3;
        n--;
    }
   // cout << il_0 / n << endl;
    while(il_0 / n > 3.0){
        napis += 'c';
        il_0 -= 4;
        il_1 -= 4;
        n--;
       // cout <<"h";
    }
  //  cout << il_0 << endl;
    while(il_0 / n > 2.0){
        napis += 'g';
        il_0 -= 3;
        il_1 -= 5;
        n--;
    }
    //cout << il_0 << endl;
    while(il_0 / n >= 1.0){
        napis += 'o';
        il_0 -= 2;
        il_1 -= 6;
        n--;
    }
    if(il_0 !=0 || il_1 != 0 || n != 0)
        cout << "NIE";
    else
        cout << napis;
    return 0;
}