N,K = map(int,input().split()) i = 6 count = 0 while True: c = 1 pos = 1 while pos < i: pos *= 2 if pos <= i: c += 1 S = [] for j in range(c-1,-1,-1): if i // (2**j) % 2 == 0: S.append("A") else: S.append("M") MMA = False for j in range(c-2): if S[j] == "M" and S[j+1] == "M" and S[j+2] == "A": MMA = True if MMA: count += 1 if count == K: break i += 1 for x in range(c): print(S[x],end = "") print()