#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { int64_t n, s; cin >> n >> s; s--; vector ss; auto powi = [](int64_t a, int64_t n) -> int64_t { int64_t ret = 1; for (; n; n >>= 1) { if (n & 1) { ret *= a; } a *= a; } return ret; }; for (int64_t S = 0; S < powi(3, n); S++) { string t; bool a = false, b = false, c = false; for (int64_t i = 0, T = S; i < n; i++) { t += "ABC"[T % 3]; a |= T % 3 == 0; b |= T % 3 == 1; c |= T % 3 == 2; T /= 3; } if (a && b && c) { ss.push_back(t); } } ranges::sort(ss); if (s < ss.size()) { cout << ss[s] << endl; } else { cout << -1 << endl; } return 0; }