#include <stdio.h> 
#include <string.h>

/*typedef struct Student
    {int a;
    }Stu;
这里的Stu实际上就是struct Student的别名。Stu==struct Student
声明变量的时候就可:Stu stu1  或者 struct Student stu1
也可不写Student  只用 Stu stu1
*/
typedef struct  wordline
{
    char word[1000];
    struct  wordline *next;
    struct  wordline *prior;   
}wordline;
//循环双链表尾插法存储后逆序输出
int main() { 

    wordline* h;
    wordline* t;
    wordline* p;
    h= (wordline*)malloc(sizeof(wordline));
    h->next = h;
    h->prior =h;
    t = h;
    char str[1000];
    int num=0;
    while(scanf("%s",str)!=EOF){
     p= (wordline*)malloc(sizeof(wordline));
        strcpy(p->word, str);
        p->prior = t;
        p->next = h;
        t ->next = p;
        h->prior = p;
        t = p;
   }
   
   wordline* k;
   k = t;
   while(k!=h){
        printf("%s ",k->word);
       k = k->prior;
   }

   
  
return 0; 
}