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
65
66
//Author: Piotr Zielinski
#include<bits/stdc++.h>
using namespace std;

template<class C> C reversed(C c) {reverse(c.begin(),c.end()); return c;}
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(X) (X).begin(), (X).end()
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
typedef pair<int,int> pii;

int32_t main(){
    ios::sync_with_stdio(false);
    int n;
    string str;
    cin >> n >> str;

    vector<int> ct(2);

    for(int i = 0;i < 8 * n;++i) {
        ct[str[i] - '0']++;
    }

    if((ct[0] & 1) != (ct[1] & 1) || ct[0] > (ct[1] + 2 * n) || ct[1] > (ct[0] + 4 * n)) {
        cout << "NIE\n";
        return 0;
    }


    stringstream res;
    for(int i = 0;i < n;++i) {
        if(ct[0] > ct[1]) {
            res << 'a';
            ct[0] -= 5;
            ct[1] -= 3;
        }
        else if(ct[1] > ct[0]) {
            if(ct[1] - 4 >= ct[0]) {
                res << 'o';
                ct[0] -= 2;
                ct[1] -= 6;
            }
            else {
                res << 'g';
                ct[0] -= 3;
                ct[1] -= 5;
            }
        }
        else {
            res << 'c';
            ct[0] -= 4;
            ct[1] -= 4;
        }
    }
    if(ct[0] != 0 || ct[1] != 0) {
        cout << "NIE\n";
        return 0;
    }

    res << '\n';
    cout << res.str();

    return 0;
}