#include<stdio.h>
#include<stdlib.h>
struct node* head;
struct node{
long long data;
struct node* next;
};
void insert(long long x)
{
struct node* temp1=(node*)malloc(sizeof(struct node));
temp1->data=x;
struct node* temp2=head;
if(head==NULL)
{
head=temp1;
head->next=NULL;
}
else
{
while(temp2->next!=NULL)
{
temp2=temp2->next;
}
temp1->next=NULL;
temp2->next=temp1;
}
}
void print()
{
struct node* temp=head;
while(temp!=NULL)
{
printf("%lld ",temp->data);
temp=temp->next;
}
}
int main()
{
long long n,i,x;
head=NULL;
scanf("%lld",&n);
for(i=0;i<n;i++)
{
scanf("%lld",&x);
insert(x);
print();
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CnN0cnVjdCBub2RlKiBoZWFkOwpzdHJ1Y3Qgbm9kZXsKCWxvbmcgbG9uZyBkYXRhOwoJc3RydWN0IG5vZGUqIG5leHQ7Cn07CnZvaWQgaW5zZXJ0KGxvbmcgbG9uZyB4KQp7CglzdHJ1Y3Qgbm9kZSogdGVtcDE9KG5vZGUqKW1hbGxvYyhzaXplb2Yoc3RydWN0IG5vZGUpKTsKCXRlbXAxLT5kYXRhPXg7CglzdHJ1Y3Qgbm9kZSogdGVtcDI9aGVhZDsKCWlmKGhlYWQ9PU5VTEwpCgl7CgkJaGVhZD10ZW1wMTsKCQloZWFkLT5uZXh0PU5VTEw7Cgl9CgllbHNlCgl7CgkJd2hpbGUodGVtcDItPm5leHQhPU5VTEwpCgkJewoJCQl0ZW1wMj10ZW1wMi0+bmV4dDsKCQl9CgkJdGVtcDEtPm5leHQ9TlVMTDsKCQl0ZW1wMi0+bmV4dD10ZW1wMTsKCX0KfQp2b2lkIHByaW50KCkKewoJc3RydWN0IG5vZGUqIHRlbXA9aGVhZDsKCXdoaWxlKHRlbXAhPU5VTEwpCgl7CgkJcHJpbnRmKCIlbGxkICIsdGVtcC0+ZGF0YSk7CgkJdGVtcD10ZW1wLT5uZXh0OwoJfQp9CmludCBtYWluKCkKewogICAgIGxvbmcgbG9uZyBuLGkseDsKCSBoZWFkPU5VTEw7Cgkgc2NhbmYoIiVsbGQiLCZuKTsKCSBmb3IoaT0wO2k8bjtpKyspCgkgewoJIAlzY2FuZigiJWxsZCIsJngpOwogICAgICAgIGluc2VydCh4KTsKICAgICAgICBwcmludCgpOwoJCSB9CQp9Cg==