#把字母的单词找到,再用空格连接,逆序输出
# import sys
while True:
    try:
        s = input()
        words = []
        word = ''
        for c in s:
            if c.isalpha():
                word += c 
            else:
                if word != '':
                    words.append(word)
                    word = ''
        if word != '':
            words.append(word)
            word = ''
        print(' '.join(words[::-1]))
    except:
#         print(sys.exc_info())
        break