#include<stdio.h>
#include<stdlib.h>
typedef struct list
{
    int data;
    struct list *next;
}node;
node *head=NULL,*tail=NULL;
void create(int n)
{
    node *nd=(node*)malloc(sizeof(node));
    nd->data=n;
    nd->next=NULL;
    if(head==NULL)
    {
        head=tail=nd;
    }
    else
    {
        tail->next=nd;
        tail=nd;
    }
}
void print()
{
    node *temp=head;
    while(temp!=NULL)
    {
        printf("%d ",temp->data);
        temp=temp->next;
    }
    printf("\n");
    node *temp2=head;
    while(temp2->next!=NULL)
    {
        printf("%d ",temp2->data);
        temp2=temp2->next;
    }
}

int main()
{
    int n,data;
    scanf("%d",&n);
    if(n<0)
    {
        printf("Invalid input");
        return 0;
    }
    else
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",itr->data);
            create(data);
        }
        print();
    }
}