#include<stdio.h>
#include<string.h>
typedef struct Stack
{
    int top;
    char c[100000];
}Stack;
void init(Stack &s)
{
   s.top=0;
}
void push(Stack &s,char c)
{
  
    s.c[s.top++]=c;
}
int pop(Stack &s,char *p)
{
   int i=0;
    while(s.top>0&&(*p++=s.c[--s.top])!=' ') 
    {
        i++;
    }
    return i-1;
}
void rev(Stack &s)
{
   char c[100];
    while(s.top>0)
    {
        int i=pop(s,c);
        for(;i>=0;i--)
        {
            printf("%c",c[i]);
        }
        printf(" ");
    }
    printf("\n");
}
int main()
{
 Stack s;
 init(s);
 char c[1000];
 gets(c);
 for(int i=0;i<strlen(c);i++)
     push(s,c[i]);
 rev(s);
return 0;
}