#include <iostream>
#include <stack>
using namespace std;
int main()
{
string str;
string seperator(" ");
stack<string> words;
while(getline(cin,str)){
string::size_type startPos=0,endPos=0;
while(words.empty()==false)
words.pop();
while((startPos=str.find_first_not_of(seperator,endPos))!=string::npos){
int spaceNum=startPos-endPos;
int cnt=1;
while(cnt<=spaceNum){
words.push(string(" "));
++cnt;
}
endPos=str.find_first_of(seperator,startPos);
string word;
word.assign(str,startPos,endPos-startPos);
words.push(word);
}
while(words.empty()==false){
string tmpWord=words.top();
words.pop();
cout<<tmpWord;
}
cout<<endl;
}
return 0;
}
/**************************************************************
Problem: 1361
User: lcyvino
Language: C++
Result: Accepted
Time:260 ms
Memory:1656 kb
****************************************************************/