#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
struct Node
{
int data;
Node *next;
};
Node *Create()
{
Node *head=NULL;
int data;
while(scanf("%d",&data) && data > 0)
{
Node *p=(Node*)malloc(sizeof(Node));
p->data=data;
if(head == NULL)
{
head=p;
head->next=NULL;
}
else
p->next=head;
head=p;
}
return head;
}
int main()
{
Node *root;
root=Create();
Node *p=root;
for(;p != NULL;p=p->next)
{
cout<<p->data<<' ';
}
cout<<endl;
}