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


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; 
	cin>>n; 
	string s;
	cin>>s; 
	int ile1=0,ile0=0;
	for(int i=0;i<(int)s.size();i++){ 
		if(s[i]=='1') ile1++; 
		else ile0++;
	}
	vector<pair<char,int>> lit; 
	lit.push_back(make_pair('a',3));
	lit.push_back(make_pair('c',4));
	lit.push_back(make_pair('g',5));
	lit.push_back(make_pair('o',6));
	string ans="";
	int p1,p2,p3,p4;
	while(true){
		p1=ile0;
		p2=ile0;
		p3=ile1;
		p4=ile1;
		//cout<<ile0<<" "<<ile1<<"\n";
		if(ile1-3>=0 && ile0-5>=0){
			ile1-=3; 
			ile0-=5; 
			p2-=3;
			p4-=5;
			ans+='a';
			//cout<<ans<<"\n";
		}
		if(ile1-4>=0 && ile0-4>=0){
			ile1-=4; 
			ile0-=4; 
			p2-=4;
			p4-=4;
			ans+='c';
			//cout<<ans<<"\n";
		}
		if(ile1-5>=0 && ile0-3>=0){
			ile1-=5; 
			ile0-=3; 
			p2-=5;
			p4-=3;
			ans+='g';
			//cout<<ans<<"\n";
		}
		if(ile1-6>=0 && ile0-2>=0){
			ile1-=6; 
			ile0-=2; 
			p2-=6;
			p4-=2;
			ans+='o';
			//cout<<ans<<"\n";
		}
		//cout<<ile0<<" "<<ile1<<"\n";
		if(p1==p2 && p3==p4){
			cout<<"NIE\n";
			return 0;
		}
		if(ile1==0 && ile1==ile0){
			cout<<ans<<"\n";
			return 0;
		}
	}
}