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
#include <iostream>

using namespace std;

const int maxN = 100000;

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

  int n; cin>>n;
  char c;
  int zeros = 0;
  int ones = 0;

  for(int i=0; i<8*n; i++){
    cin>>c;
    if(c == '1')
      ones++;
    else
      zeros++;
  }

  zeros -= 2*n;
  ones -= 3*n;

  if(zeros < 0 or ones < 0){
    cout<<"NIE\n";
    return 0 ;
  }

  while(zeros >= 3){
    cout<<'a';
    zeros-=3;
  }
  while (ones >= 3){
    cout<<'o';
    ones-=3;
  }

  if(ones == 1){
    cout<<"c";
  }
  if(ones == 2){
    cout<<"g";
  }

  cout<<"\n";
}