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

/* a3 b3 d3 h3 p3
c4 e4 f4 i4 j4 l4 q4 r4 t4 x4
g5 k5 m5 n5 s5 u5 v5 y5 z5
o6 w6
*/

int main() {
    ios_base::sync_with_stdio(0);
    int a; string n; 
    cin >> a; cin >> n;
    int jedynki = 0, zera = 0;
    for (int i = 0; i < a*8; i++) {
        if (n[i] == '0') zera++;
        else if (n[i] == '1') jedynki++;
    }
    if (jedynki < a * 3) cout << "NIE";
    else if (jedynki > a * 6) cout << "NIE";
    else {
        int tmp = jedynki - 3 * a;
        if (tmp == 0) for (int i = 0; i < a; i++) cout << "a";
        else {
            int tmp2 = tmp % 3;
            int tmp3 = floor(tmp / 3);
            int tmp4 = tmp2 % 2;
            int tmp5 = floor(tmp2 / 2);
            int wyn = 0;
            for (int i = 0; i < tmp3; i++) {
                wyn++;
                cout << "o";
            }
            if (tmp2 != 0) {
                for (int i = 0; i < tmp5; i++) {
                    wyn++;
                    cout << "g";
                }
                if (tmp4 != 0) {
                    for (int i = 0; i < tmp4; i++) {
                        wyn++;
                        cout << "q";
                    }
                }
            }
            if (wyn > a) cout << "wtf";
            if (wyn < a) {
                for (int i = 0; i < a - wyn; i++) cout << "a";
            }
        }
    }
    return 0;
}