1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdio>
using namespace std;

#define FOR(i,a,b) for(int (i)=(int)(a); (i)!=(int)(b); ++(i))

char C[8] = "...acgw";

int n;
char S[800010];
int main() {
    scanf("%d", &n);
    scanf("%s", S);

    int x = 0;
    FOR(i,0,8*n) if (S[i] == '1') ++x;
    if (x<3*n || x>6*n) { printf("NIE\n"); return 0; }
    int k = x/n;
    int a = (k+1) * n - x;
    FOR(i,0,a) printf("%c", C[k]);
    FOR(i,a,n) printf("%c", C[k+1]);
    printf("\n");
}