#include <iostream>
#include <string>
#include <stack>
int main()
{
std::stack<std::string> stk ;
std::string current_str ;
char c ;
while( std::cin.get(c) ) // read char by char
{
if( std::isspace(c) ) // if it is a whitespace
{
if( !current_str.empty() ) stk.push(current_str) ; // end of current string, push it
current_str.clear() ; // start afresh with an empty new string
if( c == '\n' ) break ; // newline, come out of the loop
}
else current_str += c ; // not whitespace, append to current string
}
// if current string is not empty, push it (eof on std::cin)
if( !current_str.empty() ) stk.push(current_str) ;
while( !stk.empty() )
{
std::cout << stk.top() << ' ' ;
stk.pop() ;
}
std::cout << '\n' ;
}