n=int(input()) s=int(input()) a=[] for i in range(3**n): b=[] A=False B=False C=False for j in range(n): x=i//pow(3,j)%3 if x==0: b.append('A') A=True elif x==1: b.append('B') B=True else: b.append('C') C=True if A and B and C: a.append(''.join(b)) a.sort() if s<=len(a): print(a[s-1]) else: print(-1)