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
#include <cstdio>
using namespace std;

int main() {
	int n, suma1 = 0;
	scanf("%d\n", &n);

	char c;
	for (int k=0; k<8*n; k++) {
		scanf("%c", &c);
		if(c == '1') suma1++;
	}

	if(suma1 < 3*n || suma1 > 6*n) {
		printf("NIE");
		return 0;
	}

	int srednia = suma1 / n, dodatek = suma1 - n*srednia;

	for (int k=0; k<n; k++) {
		int s = srednia + (k < dodatek);
		switch(s) {
			case 3: printf("a"); break;
			case 4: printf("c"); break;
			case 5: printf("g"); break;
			case 6: printf("o"); break;
		}
	}	

	return 0;
}