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

#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define vb vector<bool>
#define vvb vector<vb>
#define vl vector<ll>
#define endl '\n'
#define turbo ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define f first
#define s second

using namespace std;

int n;

int main()
{
    turbo
    string s; cin >> n >> s;
    vi t(2, 0);
    for(auto it  : s)
        t[it-'0']++;
    string res;
    for(int i = 0; i < n; i++)
        res+='w';
    t[1]-=n*6;
    t[0]-=n*2;
    for(int i = 0; i < n; i++)
    {
        if(t[1] <= -3)
        {
            res[i] = 'a';
            t[1]+=3;
            t[0]-=3;
        }
        else if(t[1] == -2)
        {
            res[i] = 'f';
            t[1]+=2;
            t[0]-=2;
        }
        else if(t[1] == -1)
        {
            res[i] = 'm';
            t[1]++;
            t[0]--;
        }
        else break;
    }
    if(t[0] == t[1] and !t[0])
        cout << res << endl;
    else cout << "NIE\n";
}