#include<stdlib.h>
#include<stdio.h>
typedef struct node{
int data;
struct node *next;
}Node,*LNode;
bool Initlist(Node* &l){
l = (Node*)malloc(sizeof(Node));
if(l == NULL)
return false;
l->next = NULL;
return true;
}
void add(Node *list,int data){
Node *p;
if(!Initlist(p)){
printf("error!");
}
p->data = data;
p->next = list->next;
list->next = p;
}
int main(){
Node *list;
if(!Initlist(list)){
printf("error!");
return 0;
}
int data;
scanf("%d",&data);
while(data != 1234){
add(list,data);
scanf("%d",&data);
}
while(list->next != NULL){
list = list->next;
printf("%d\n",list->data);
}
}