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
#include <iostream>
#include <vector>
using namespace std;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector <int> ilosc(2, 0);
    for (int i=0;i<8*n;i++) {
        char x;
        cin >> x;
        ilosc[x-'0']++;
    }
    // cout << ilosc[0] << ' ' << ilosc[1] << endl;

    vector <int> litery(n, (int)(ilosc[1]/n));
    for (int i=0;i < (ilosc[1]%n); i++)
        litery[i]++;

    vector <char> litery2;
    litery2.push_back('a');
    litery2.push_back('f');
    litery2.push_back('n');
    litery2.push_back('o');

    if (litery[0]>6 || litery[n-1]<3)
        cout << "NIE";
    else
        for (int k: litery)
            cout << litery2[k-3];

    cout << '\n';

    return 0;
}