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

int main() {
    string s;
    while (getline(cin,s)) { // 注意 while 处理多个 case
        vector<string> words;
        string word;
        s += " ";
        for(char c: s){
            if(isalpha(c)){
                word += c;
            } else {
                if(!word.empty()){
                    words.push_back(word);
                    word.clear();
                }
            }
        }
        for(int i = words.size() - 1; i >= 0; i--){
            cout << words[i] << " ";
        }
        cout << endl;
    }
}
// 64 位输出请用 printf("%lld")