#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
while(getline(cin, str)){
vector<vector<char>> vvc;
vector<char> vc;
for(int i = 0 ; i < str.size(); i++){
if(isalpha(str[i])){
vc.push_back(str[i]);
}
else{
if(vc.size() > 0){
vvc.push_back(vc);
vc.clear();
}
}
}
if(vc.size()){
vvc.push_back(vc);
}
vector<string> vs;
for(int i = 0; i < vvc.size(); i++){
string temp;
temp.resize(vvc[i].size());
for(int j = 0; j < vvc[i].size(); j++){
temp[j] = vvc[i][j];
}
vs.push_back(temp);
temp.clear();
}
for(int i = 0; i < vs.size(); i++){
cout << vs[vs.size() - 1 - i] << ' ';
}
cout << endl;
}
return 0;
}