//递归实现
#include <iostream>
#include <cstdio>
using namespace std;
class node
{
public:
int data;
node * next;
node(int d):data(d),next(NULL)
{
}
};
class lists
{
node * head;
node * tail;
public:
lists();
void add(int d);
void order(node*);
void output();
};
lists::lists()
{
head=NULL;
tail=NULL;
}
void lists::add(int d)
{
node * p=new node(d);
if(head==NULL)
{
head=p;
tail=head;
}
else
{
tail->next =p;
tail=p;
}
}
void lists::output() //我好机智啊
{
order(head);
}
void lists::order(node * tmp)
{
if(tmp->next!=NULL)
{
order(tmp->next);
}
printf("%d",tmp->data);
}
int main()
{
lists l;
int data;
//freopen("in.txt","r",stdin);
while(cin>>data&&data!=-1)
{
l.add(data);
}
l.output();
}