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

int maxI(int depth, int bits, int n) {
  return ((bits - (6 * n)) / (depth - 6)) + 6;
}

bool calc(int *data, int depth, int bits, int n) {
  if (bits <= 0 || n <= 0) {
    return false;
  }

  if (bits / depth == n && bits % depth == 0) {
    data[depth - 3] = n;
    return true;
  }

  if (depth == 6) {
    return false;
  }

  // DEBUG
//  fprintf(stderr, "mi: %d\n", maxI(depth, bits, n));

  for (int i = maxI(depth, bits, n); i >= 0; --i) {
    int remainingBits = bits - (i * depth);
    int remainingN = n - i;

    if (remainingN * depth + 1 > remainingBits) {
      return false;
    }

    if (calc(data, depth + 1, remainingBits, remainingN) == true) {
      data[depth - 3] = i;
      return true;
    }
  }

  return false;
}

void print(char c, int count) {
  for (int i = 0; i < count; ++i) {
    std::cout << c;
  }
}

int main() {
  int N = 0;
  std::cin >> N;

  int ones = 0;

  for (int i = 0; i < 8 * N; ++i) {
    char b = '\0';
    std::cin >> b;

    if (b == '1') {
      ones++;
    }
  }

  // DEBUG
//  fprintf(stderr, "bits: %d, n: %d\n", ones, N);

  //////////////////////

  int data[4] = {0, 0, 0, 0};
  if (calc(data, 3, ones, N) == false) {
    std::cout << "NIE";
  } else {
    print('a', data[0]);
    print('c', data[1]);
    print('u', data[2]);
    print('o', data[3]);
  }
  std::cout << std::endl;
  return 0;
}