#include #include #include void solve() { int n; std::cin >> n; std::vector grundy(n + 1, 0); for (int x = 2; x <= n; ++x) { std::set gs; if (x % 2 == 0) { gs.insert(0); } else { gs.insert(grundy[x / 2] ^ grundy[x / 2 + 1]); } if (x >= 3) { if (x % 3 == 1) { gs.insert(grundy[x / 3 + 1]); } else { gs.insert(grundy[x / 3]); } } auto& g = grundy[x]; while (gs.count(g)) ++g; } std::cout << (grundy[n] == 0 ? "B" : "A") << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }