str = input().split(' ')
print(str)
str_list = []
for x in str:
str_list.append(len(x))
str[str_list.index(max(str_list))], str[str_list.index(min(str_list))] = str[str_list.index(min(str_list))], str[str_list.index(max(str_list))]
str = input().split(' ')
print(str)
str_list = []
for x in str:
str_list.append(len(x))
str[str_list.index(max(str_list))], str[str_list.index(min(str_list))] = str[str_list.index(min(str_list))], str[str_list.index(max(str_list))]
print(str)