#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;


/*
思路:如果字符串的非字母的单词输入vector<string>, 排序后输出
*/
string veverseString(string strIn)
{
    int strInLen = strIn.length();
    string strOut, strTemp;
    vector<string> strVec;
    for(int i = 0; i < strInLen; i++) {
        if(strIn[i] >= 'a' && strIn[i] <= 'z' || strIn[i] >= 'A' && strIn[i] <= 'Z'){
            strTemp += strIn[i];
        } else {
            strVec.push_back(strTemp);
            strTemp.clear();
        }
        
        if(i == strInLen - 1) {
             strVec.push_back(strTemp);
        }
    }
    reverse(strVec.begin(), strVec.end());
    
    int i = 0;
    for(auto iter = strVec.begin(); iter != strVec.end(); iter++) {
        if(i == 0) {
             strOut += *iter;
            i++;
        } else {
             strOut += ' ' + *iter;
        }
       
    }
    return strOut;
}
int main()
{
    string strIn;
    while(getline(cin, strIn)) {
        cout<<veverseString(strIn)<<endl;
    }
}