# url: https://stepik.org/lesson/265115/step/8?thread=solutions&unit=246063

a, b, c = input(), input(), input()
print(min(a, b, c, key=len))
print(max(a, b, c, key=len))

# alternative:

[print(min(x, key=len), max(x, key=len), sep="\n") for x in [[input() for _ in "abc"]]]