#include<iostream>
#include<malloc.h>
#include<cstdio>
using namespace std;
struct List{
int data;
List* next;
}*list;
void List_made(){
int t;
list = new List;
list->next = NULL;
List *p;
List *head = new List;
head = list;
while(scanf("%d" , &t) && t != 0){
if(list->next == NULL){
p = new List;
p->data = t;
p->next = list->next;
list->next = p;
head = p;
}
else{
p = new List;
p->data = t;
p->next = head->next;
head->next = p;
head = p;
}
}
}
void read_list(){
List *p = new List;
int l = 0;
p = list->next;
while(p!=NULL){
printf("%d\n" , p->data);
p = p->next;
}
}
int main()
{
List_made();
read_list();
}