ll=list(input())
countA = ll.count('A')
countB = ll.count('B')
if countA == countB:
print('E')
elif countA > countB:
print('A')
else:
print('B')
ll=list(input())
countA = ll.count('A')
countB = ll.count('B')
if countA == countB:
print('E')
elif countA > countB:
print('A')
else:
print('B')