import math,itertools n=list(itertools.permutations(input())) for i in range(len(n)): n[i]="".join(n[i]) print(math.gcd(n))