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

int main() {
    vector<string> vec; //store word
    string str;
    while (getline(cin, str)) {
        str = str + ' ';
        string temp;
        for (char& i : str) {
            if ( i != ' ')
                temp.append(1, i);
            else {
                vec.push_back(temp);
                temp.clear();//清空temp
            }
        }
        reverse(vec.begin(), vec.end());
        for (string s : vec)
            cout << s << " ";
    }
    return 0;
}