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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <bits/stdc++.h>

using namespace std;

char pairToChar(pair<int, int> a) {
  if (a.first == 3 && a.second == 5) {
    return 'a';
  }
  if (a.first == 5 && a.second == 3) {
    return 'g';
  }
  if (a.first == 6 && a.second == 2) {
    return 'o';
  }
  if (a.first == 4 && a.second == 4) {
    return 'c';
  }

  return 'z';
}

int n;
string s;
int cnt0, cnt1;
string res;

void solveEqual() {
  while (cnt0 > 0) {
    cnt0 -= 4;
    res.push_back('c');
  }
  cout << res << endl;
}

int main() {
  cin >> n;
  cin >> s;
  for (auto c : s) {
    if (c == '0') {
      cnt0++;
    } else {
      cnt1++;
    }
  }

  while (cnt0 > cnt1) {
    res += 'a';
    cnt0 -= 5;
    cnt1 -= 3;
  }
  // cout << cnt0 << " " << cnt1 << endl;
  if (cnt0 == cnt1 && (cnt0 < 0 || cnt0 % 4 != 0)) {
    cout << "NIE" << endl;
    return 0;
  }
  if (cnt1 == cnt0 && cnt0 % 4 == 0) {
    solveEqual();
    return 0;
  }

  // cout << cnt1 << " " << cnt0 << endl;
  for (int i = 0; i <= n; ++i) {
    int x4 = cnt1 - cnt0 - 2 * i;
    if (x4 < 0) {
      continue;
    }
    if (x4 % 4 != 0) {
      continue;
    }
    int x = x4 / 4;

    for (int j = 1; j <= i; ++j) {
      cnt1 -= 5;
      cnt0 -= 3;
      res.push_back('g');
    }
    for (int j = 1; j <= x; ++j) {
      cnt1 -= 6;
      cnt0 -= 2;
      res.push_back('o');
    }
    // cout << cnt1 << " " << cnt0 << endl;
    if (cnt0 == cnt1 && (cnt0 < 0 || cnt0 % 4 != 0)) {
      continue;
    }
    if (cnt0 < 0 || cnt1 < 0) {
      continue;
    }
    solveEqual();
    // cout << res << endl;
    return 0;
  }
  cout << "NIE" << endl;
}