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
// 
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, p, k) for(int i(p); i < k; ++i)
typedef long long int ll;
typedef long double ld;
template <typename T = int> inline T in()
{
    T x;
    std::cin >> x;
    return x;
}
bool z()
{
    std::cout << "NIE\n";
    return 0;
}
int main()
{
    std::cin.tie(nullptr); std::cout.tie(nullptr); std::ios_base::sync_with_stdio(0);
    int n(in()), r(0);
    rep(i, 0, 8*n)r -= 1 - 2*(in<char>() - '0');
    if(r % 1)return z();
    r /= 2;
    if(r < -n || r > 2*n)return z();
    int a, g, o, c;
    if(r < 0)
    {
        a = -r;
        c = n+r;
        o = g = 0;
    }
    else
    {
        o = r/2;
        g = r % 2;
        c = n-o-g;
        a = 0;
    }
    while(a--)std::cout << 'a';
    while(g--)std::cout << 'g';
    while(o--)std::cout << 'o';
    while(c--)std::cout << 'c';
    std::cout << '\n';
    return 0;
}