#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); long long N; cin >> N; set taste; set::iterator itr, temp; string ans; taste.insert(1); for (itr = taste.begin(); itr != taste.end() && *itr < N; ++itr) taste.insert(*itr * 2 + 1), taste.insert(*itr * 3 + 1); if (*itr != N) { cout << "Impossible!\n"; return 0; } while (*itr != 1) { if ((*itr - 1) % 2 == 0 && (temp = taste.find((*itr - 1) / 2)) != taste.end()) ans.push_back('A'), itr = temp; else if ((*itr - 1) % 3 == 0 && (temp = taste.find((*itr - 1) / 3)) != taste.end()) ans.push_back('B'), itr = temp; } reverse(ans.begin(), ans.end()); cout << ans << '\n'; return 0; }