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

void solve(int n, int b) {
  const map<int, char> M = {{0, 'a'}, 
                            {1, 'c'}, 
                            {2, 'g'}};
  const int o = (b - 3*n)/3, a = n - o - 1, r = b%3;
  cout << string(o, 'o');
  if (o < n)
    cout << string(a, 'a') << string(1, M.at(r));
}

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

  int n; cin >> n;
  int b = 0;
  { string s; cin >> s; for (auto& c : s) b += c == '1'; }
  if (b < 3*n or 6*n < b) {
    cout << "NIE";
    return 0;
  }
  solve(n, b);
}