#include<bits/stdc++.h>
using namespace std;
class node{
public:
int data;
node *next;
node(int d)
{
data=d;
next=NULL;
}
};
void insertAtHead(node *&head,int d)
{
//cout<<" d “<<d<<” "<<endl;
if(head==NULL)
{
head=new node(d);
return;
}
else{
node *tem=new node(d);
tem->next=head;
head=tem;
return;
}
}
void print(node *head)
{
node *tem=head;
while(tem->next!=NULL)
{
cout<<tem->data<<"->";
tem=tem->next;
}
cout<<tem->data<<endl;
}
node *takeInput()
{
int d;
node *head=NULL;
while(cin>>d)
{
cout<<d<<endl;
insertAtHead(head,d);
}
return head;
}
int main()
{
node *head=takeInput();
print(head);
}