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
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <typeinfo>

#define c_plus_plus std
#define QED return 0
#define NOT_QED return -1
#define CNU return
#define kiedy_kliknieto_zielona_flage int main()

#define ll long long
#define mp make_pair
//#define str string
#define vec vector
#define pb push_back
#define foru(u, n) for(int u=0;u<n;u++)
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807LL
#define ir(a, b, x) ((a<=x)&&(x<=b))
#define f first
#define s second
#define ll long long
#define vll vec<ll>
#define p pair<ll, ll>

using namespace c_plus_plus;

ll get_num(){
    ll ans = 0;
    char ch;
    while(ch = getchar()){
        if(ch<='9' && ch>='0') ans = 10*ans + ch - '0';
        else return ans;
    }

}

kiedy_kliknieto_zielona_flage{

    int n = get_num();
    int cnt = 0;
    for(int i=0;i<8*n;i++){
        cnt += (getchar()=='1');
    }

    #define x3 "a"
    #define x4 "c"
    #define x5 "g"
    #define x6 "o"

    #define legit_range(o, n) ((o)>=(3*(n))&&(o)<=(6*(n)))

    string str = "";
    while(n!=0){
        n--;
        if(legit_range(cnt-3, n)) {cnt-=3; str+=x3; continue;}
        if(legit_range(cnt-4, n)) {cnt-=4; str+=x4; continue;}
        if(legit_range(cnt-5, n)) {cnt-=5; str+=x5; continue;}
        if(legit_range(cnt-6, n)) {cnt-=6; str+=x6; continue;}
        printf("NIE");
        QED;
    }
    printf("%s", str.c_str());

    QED;
}