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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    long long n;
    cin>>n;

    string code;
    cin>>code;
    vector<int> binary(8*n);

    long long one_counter=0;

    for(int i=0;i<8*n;i++)
    {
        binary[i]=code[i]-'0';

        if(binary[i]==1)
        {
            one_counter++;
        }
    }

    //cout<<one_counter<<endl;

    long long counter_3=0;
    long long counter_4=0;
    long long counter_5=0;
    long long counter_6=0;

    if((3*n)<=one_counter && one_counter<=(6*n))
    {
        long long rest=one_counter-(3*n);

        counter_6=rest/3;

        if(rest%3==1)
        {
            counter_4++;
        }
        else if (rest%3==2)
        {
            counter_5++;
        }

        counter_3=n-counter_4-counter_5-counter_6;

        //cout<<counter_3<<" "<<counter_4<<" "<<counter_5<<" "<<counter_6<<endl;

        for(int i=0;i<counter_3;i++)
        {
            cout<<"p";
        }

        for(int i=0;i<counter_4;i++)
        {
            cout<<"q";
        }

        for(int i=0;i<counter_5;i++)
        {
            cout<<"m";
        }

        for(int i=0;i<counter_6;i++)
        {
            cout<<"w";
        }

        cout<<endl;
        
    }
    else
    {
        cout<<"NIE"<<endl;
    }
    

    return 0;
}