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
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <numeric>
#include <map>
#include <string>

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::map<int,char> letters= {{3,'a'}, {4,'f'}, {5,'g'}, {6,'w'}, {7,'3'}};
    long long int n;
    std::string s;
    std::cin>>n>>s;
    long long int sum = std::count(s.begin(),s.end(),'1');
    if(sum < 3*n || sum > 6*n)
        std::cout<<"NIE"<<std::endl;
    else
    {
        char first = letters.at(sum/n), second =letters.at(sum/n +1);
        long long int q = sum % n;
        std::string s1(n-q, first);
        std::string s2(q, second);
        std::cout<<s1+s2<<std::endl;
    }
    return 0;
}