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

using namespace std;
typedef long long int lli;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    lli n;
    string s;
    cin >> n;
    cin >> s;
    vector<lli> counts(2);
    for (int i = 0; i < 8 * n; i++) {
        counts[s[i]-'0']++;
    }
    counts[0] -= 2 * n;
    counts[1] -= 3 * n;
    if (counts[0] < 0 || counts[1] < 0) {
        cout << "NIE" << '\n';
        return 0;
    }
    string res("");
    for (int i = 0; i < n; i++) {
        if (counts[1] >= 3) {
            res += 'w';
            counts[1] -= 3;
        } else if (counts[1] == 2) {
            res += 'n';
            counts[1] -= 2;
        } else if (counts[1] == 1) {
            res += 'c';
            counts[1]--;
        } else {
            res += 'a';
        }
    }
    cout << res << '\n';
    return 0;
}