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
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
//Krzysztof Pieprzak
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define Size(x) (int)x.size()
#define VAR(v,n) auto v = (n)
#define FOR(i,a,b) for(VAR(i,a); i < (b); ++i)
#define FORE(i,a,b) for(VAR(i,a); i <= (b); ++i)
#define FORREV(i,a,b) for(VAR(i,b); i >= (a); --i)
#define FORSTEP(i,a,b,step) for(VAR(i,a); i < (b); i += (step))
#define FOREACH(i,c) for(auto i : (c))
#define FOREACHS(i,c,n) for(VAR(i,&(c)[0]); i-(c)<(n); ++i)
#define ALL(x) x.begin(),x.end()
#define CLEAR(t) memset(t, 0, sizeof(t))
#define F first
#define S second
#define MP make_pair
#define PUB push_back
#define POB pop_back
#define pieprzu ios_base::sync_with_stdio(0);

#define debugOn 0
#define debug(x) if (debugOn) cout << x << endl;
#define debugDesc(a,b) if (debugOn) cout << a << ": " << b << endl;

const int    INF = 1000000001;
const double EPS = 10e-9;

const int MAXN = 100000;

char s[8 * MAXN + 5];
char result[MAXN + 5];

char getLetter(int onesInLetter) {
    debugDesc("onesInLetter", onesInLetter);
    if (onesInLetter == 1) {
        return 'a';
    } else if (onesInLetter == 2) {
        return 'c';
    } else if (onesInLetter == 3) {
        return 'g';
    } else { // 4
        return 'o';
    }
}

void rob(int test) {
    int n;
    scanf("%d", &n);
    scanf("%s", s);

    int sSize = 8 * n;
    int ones = 0;
    FOR (i, 0, sSize) {
        ones += s[i] - '0';
    }
    debugDesc("ones", ones);

    ones -= 2 * n;
    debugDesc("ones", ones);

    if (ones < 0) {
        printf("NIE\n");
        return;
    }

    int onesInEachLetter = ones / n;
    int lettersWithAdditionalOne = ones % n;
    debugDesc("each letter", onesInEachLetter);
    debugDesc("additional", lettersWithAdditionalOne);

    if (onesInEachLetter <= 0 || onesInEachLetter > 4 || (onesInEachLetter == 4 && lettersWithAdditionalOne > 0)) {
        printf("NIE\n");
        return;
    }

    FOR (i, 0, n) {
        result[i] = getLetter(onesInEachLetter + (i < lettersWithAdditionalOne ? 1 : 0));
    }
    printf("%s\n", result);
}

int main() {
    int test = 1;
    //scanf("%d", &test);

    FORE (i, 1, test) rob(i);

    return 0;
}