#include<stdio.h>
#include<stdlib.h>
struct list{
int data;
struct list *next;
};
int main()
{
struct list *head,*end,*newnode,p;
head=NULL;
end=head;
int number;
do{
scanf("%d",&number);
if(number!=-1)
{
newnode=(struct list)malloc(sizeof(struct list));
newnode->data=number;
newnode->next=NULL;
if(head==NULL)
{
head=newnode;
end=head;
}
else
{
end->next=newnode;
end=end->next;
}
}
else
head=NULL;
}while(number!=-1);
end->next=NULL;
while(head!=NULL)
{
printf("%d ",head->data);
head=head->next;
}
return 0;
}