#include <stdio.h>
#include <malloc.h>

typedef struct Node
{
  int data;
  struct Node *prior, *next;
}node;

node *Init()
{
    node *head;
    head = (node *)malloc(sizeof(node));
    head->next = NULL;
    return head;
}

int main()
{
    int n;
    int i;
    int temp;
    node *head, *p;
    node *New;
    head = Init();
    p = head;
    scanf("%d", &n);

    for (i=0; i<n; i++)
    {
        scanf("%d", &temp);
        New = (node *)malloc(sizeof(node));
        New->data = temp;
        p->next = New;
        New->prior = p;
        p = New;
    }
    p->next = NULL;

    p = head->next;
    while (p!=NULL)
    {
        if (p->next==NULL)
        {
            printf("%d",p->data);
        }
        else
        {
            printf("%d ",p->data);
        }
        p = p->next;
    }
    printf("\n");

    p = head->next;
    while (p->next!=NULL)
    {
        p = p->next;
    }
    while (p!=head)
    {
        if (p->prior==head)
        {
            printf("%d",p->data);
        }
        else
        {
            printf("%d ",p->data);
        }
        p = p->prior;
    }
    printf("\n");
    return 0;
}