while True:
    try:
        string = input()
        string+=" " //后面添加一个空格,用于应对句子最后一个字符是字符串而无法添加的情况
        new_string = []
        sub_str =[]
        for word in string:
            if word.isalpha():
                sub_str.append(word)
            else:
                new_string.append(sub_str)
                sub_str = []
        sorted_str =[]
        for i in range(len(new_string)-1,-1,-1):
        	if new_string[i]:// 去除掉数组为空的情况
            	item="".join(new_string[i])
            	sorted_str.append(item)
        print(" ".join(sorted_str))
    
    except:
        break