'''
解题思路:
不是字母用空格代替,然后倒排
'''
s = input().strip()
#print(s)
for i in s:
if not i.isalpha():
s = s.replace(i, ' ')
#print(s)
x = s.strip().split()
#print(x)
y = x[::-1]
#print(y)
print(' '.join(y))
'''
解题思路:
不是字母用空格代替,然后倒排
'''
s = input().strip()
#print(s)
for i in s:
if not i.isalpha():
s = s.replace(i, ' ')
#print(s)
x = s.strip().split()
#print(x)
y = x[::-1]
#print(y)
print(' '.join(y))