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

#define ll long long
#define pb push_back
#define st first
#define nd second

vector<char> v;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int x = 0, y = 0;
	for(int i=0;i<8*n;i++) {
		char c;
		cin >> c;
		if(c == '1')
			x++;
		else
			y++;
	}
	for(int i=0;i<n;i++) {
		if(x < y) {
			x-=3;
			y-=5;
			v.pb('a');
		} else if(x-y >= 4) {
			x-=6;
			y-=2;
			v.pb('o');
		} else if(x-y > 0) {
			x-=5;
			y-=3;
			v.pb('g');
		} else if(x == y) {
			x-=4;
			y-=4;
			v.pb('c');
		}
	}
	if(x or y) {
		cout << "NIE\n";
		return 0;
	} 
	for(char z:v)
		cout << z;
	cout << "\n";
}