# include<iostream>
# include<stdlib.h>
using namespace std;
struct node
{
int data;
struct node *next;
};
typedef struct node node;
node *create()
{
node *head,*p,*q;
head=(node *)malloc(sizeof(node));
p=head;
int t;
while(1)
{
cin>>t;
if(t<0)
{
break;
}
q=(node*)malloc(sizeof(node));
q->data=t;
p->next=q;
p=q;
}
p->next=NULL;
return head;
}
void print(node *head)
{
node *p=head->next;
while(p!=NULL)
{
cout<<p->data<<' ';
p=p->next;
}
}
int main()
{
node *h;
h=create();
print(h);
return 0;
}