#include using namespace std; #include using namespace atcoder; using ll = long long; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K; cin >> N >> K; int cnt = 0; string ans = ""; auto dfs = [&](auto dfs, int p = 0, int prv = 0, bool f = false) -> bool { // cout << p << " " << prv << f << " " << endl; if(prv == 6) f = true; if(p == N) { cnt += f; return (cnt == K); }else { for(int c : {0, 1}) { if(dfs(dfs, p + 1, ((prv << 1) | c) & 7, f)) { ans += "AM"[c]; return true; } } return false; } }; dfs(dfs); reverse(ans.begin(), ans.end()); cout << ans << endl; }