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
#include <bits/stdc++.h>
#include <iostream>

//#define TEST

using namespace std;

#define FAST  ios_base::sync_with_stdio(0) ;cin.tie(0);

typedef long long ll;



void przekierowanie()
{
#ifdef TEST
    freopen( "input.txt", "r", stdin );
    freopen( "output.txt", "w", stdout );
#endif
}


int main()
{
    FAST
    przekierowanie();

    long n;
    cin >> n;
    long L1, L0;
    L1 = L0 = 0;
    string ciag;
    cin >> ciag;
    ll x = n * 8;
    while( x -- )
    {
        auto znak = ciag[  x  ];
        if( znak == '1' )
            L1 ++;
        else
            L0 ++;
    }

    auto chk0 = L0 - (n * 2);
    auto chk1 = L1 - (n * 3);

    if( chk0 < 0 || chk1 < 0 )
    {
        cout << "NIE\n";
        return 0;
    }

    while ( n > 0 )
    {
        ll ss = L0 - L1;
        if( ss == 0 )
        {
            cout << 't';
            L1 -= 4;
            L0 -= 4;
        }
        else if( ss < 0 )
        {
            if( ss < -2 )
            {
                cout << 'o';
                L1 -= 6;
                L0 -= 2;
            }
            else
            {
                cout << 'g';
                L1 -= 5;
                L0 -= 3;
            }
        }
        else
        {
            cout << 'a';
            L0 -= 5;
            L1 -= 3;
        }
        n --;
    }
    cout << '\n';
    return 0;
}