#include<stdio.h>
#include<malloc.h>
struct node
{
int data;
struct node *next;
};
struct node *creat()
{
struct node *head,*tail,*p;
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
tail=head;
while(1)
{
p=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
if(p->data==-1)
break;
else
p->next=NULL;
tail->next=p;
tail=p;
}
return head;
}
void merge(struct node *head)
{
struct node *p,*q;
p=head->next;
head->next=NULL;
q=p->next;
while(p)
{
p->next=head->next;
head->next=p;
p=q;
if(q)
q=q->next;
}
}
void print(struct node *head)
{
struct node *p;
p=head->next;
while(p)
{
if(p==NULL)
printf("%d",p->data);
else printf("%d ",p->data);
p=p->next;
}
}
int main()
{
struct node *head;
head=creat();
merge(head);
print(head);
return 0;
}