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
#include <iostream>

using namespace std;

int main()
{
    unsigned long n, nr0 = 0, nr1 = 0, i = 0;
    char ch;
    cin >> n;
    while (i++ < 8 * n) {
        cin >> ch;
        if (ch == '0') nr0++; else nr1++;
    }
    if (nr0 < n + n || nr1 < n + n + n) {
        cout << "NIE";
        return 0;
    }
 
    for (i = 0; i < n - 1; i ++)
    {
        if (nr0 >= nr1) {
            cout << 'a';
            nr0 -= 5; nr1 -= 3;
        }
        else {
            cout << 'w';
            nr0 -= 2; nr1 -= 6;
        }
    }
    switch (nr0){
        case 2: cout << 'w'; break;
        case 3: cout << 'z'; break;
        case 4: cout << 't'; break;
        case 5: cout << 'p'; break;
    }

    return 0;
}