#include<bits/stdc++.h>
using namespace std;
int main(){
stack<char>s;
while(true){
char ch=getchar();
if(ch==' '||ch=='\n'||ch==EOF){
while(!s.empty()){cout<<s.top(); s.pop();}
if(ch=='\n'||ch==EOF)break;
cout<<endl;
}
else s.push(ch);
}
return 0;
}