#include using namespace std; #define For(i, a, b) for(int i = (a); i < (b); i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(int i = (a); i >= (b); i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() #define SZ(v) ((int)(v).size()) using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; struct SetupIo { SetupIo() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); } } setupio; int main() { int n, s; cin >> n >> s; vector vec; auto kind = [](string s) -> int { int res = 0; if (count(ALL(s), 'A')) { res++; } if (count(ALL(s), 'B')) { res++; } if (count(ALL(s), 'C')) { res++; } return res; }; auto f = [&](auto f, const string s) -> void { if (SZ(s) == n - 1 && kind(s) == 1) { return; } if (SZ(s) == n) { if (kind(s) == 3) { vec.emplace_back(s); } return; } f(f, s + 'A'); f(f, s + 'B'); f(f, s + 'C'); }; f(f, ""); sort(ALL(vec)); vec.erase(unique(ALL(vec)), vec.end()); cout << (s <= SZ(vec) ? vec[s - 1] : "-1") << "\n"; }