#pragma GCC optimize "O3,omit-frame-pointer,inline" #pragma GCC push_options #pragma GCC optimize ("unroll-loops") #define _USE_MATH_DEFINES #include using namespace std; signed main () { std::ios::sync_with_stdio(false); std::cin.tie(0); long long n; cin >> n; string ans; function dfs = [&](long long x) { if (x == 1) return true; cerr << "x = " << x << endl; x--; cerr << "x after decrement = " << x << endl; if (x % 2 == 0) { if (dfs(x / 2)) { ans += 'A'; return true; } } if (x % 3 == 0) { if (dfs(x / 3)) { ans += 'B'; return true; } } if ((x % 2 != 0) && (x % 3 != 0)) { return false; } return false; }; dfs(n); cout << ans << endl; return 0; }