banana apple kiwi fig cherry
fig kiwi apple banana cherry
words = input().split() result = sorted(words, key=lambda x: (len(x), x)) print(*result)