#include<bits/stdc++.h>
using namespace std;
struct node
{
int data;
node *next;
};
int main()
{
struct node*head;
head=new node();
head->next=NULL;
node *p, *q;
p=new node();
while(cin>>p->data&&p->data!=-1)
{
p->next=head->next;
head->next=p;
p = new node();
}
p=head->next;
while(p!=NULL)
{
if(p->next!=NULL)
cout<<p->data<<" ";
else
cout<<p->data;
p=p->next;
}
return 0;
}