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
#include <iostream>

int n, cnt;
char bit;

char letters[4] = {'a', 'c', 'g', 'o'};

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin >> n;
    for (int i = 0; i < 8 * n; i++) {
        std::cin >> bit;
        cnt += (bit == '1');
    }

    if (cnt < 3 * n || cnt > 6 * n) {
        std::cout << "NIE";
    } else {
        int base = cnt / n - 3;
        int remainder = cnt % n;
        for (int i = 0; i < remainder; i++) {
            std::cout << letters[base + 1];
        }
        for (int i = remainder; i < n; i++) {
            std::cout << letters[base];
        }
    }

    return 0;
}