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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SZ(a) ((int)(a).size())
#define ALL(a) (a).begin(), (a).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

constexpr int kInf = 1000 * 1000 * 1000 + 7;
constexpr long long kInfLL = 1e18;

// #include <atcoder/fenwicktree>
// using namespace atcoder;
// using mint = modint998244353;

char Convert(int ones) {
  int result = (1 << 6) | (1 << 5);
  ones -= 2;
  while (ones > 0) {
    --ones;
    result |= 1 << ones;
  }

  return static_cast<char>(result);
}

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  int c = count(ALL(s), '1');

  const int min_c = 3 * n, max_c = 6 * n;
  if (c < min_c || c > max_c) {
    cout << "NIE" << endl;
    return 0;
  }

  vector<int> a(n, 3);
  c -= 3 * n;
  for (int& e: a) {
    while (c > 0 && e < 6) {
      --c;
      ++e;
    }
  }

  string result;
  for (int e: a) {
    result += Convert(e);
  }

  cout << result << endl;
}