#include<stdio.h>
#include<stdlib.h>
typedef struct circle
{
    int data;
    struct circle *next;
}odd;
typedef struct circle2
{
    int data;
    struct circle2 *next;
}even;

odd *head=NULL,*tail=NULL;
even *head2=NULL,*tail2=NULL;

void oddn(int n)
{
    odd *nd=(odd*)malloc(sizeof(odd));
    nd->data=n;
    nd->next=NULL;
    if(head==NULL)
    {
        head=nd;
        tail=nd;
    }
    else
    {
        tail->next=nd;
        tail=nd;
    }
    tail->next=head;
}
void evenn(int n)
{
    odd *nd=(even*)malloc(sizeof(even));
    nd->data=n
    nd->next=NULL;
    if(head==NULL)
    {
        head2=nd;
        tail2=nd;
    }
    else
    {
        tail2->next=nd;
        tail2->nd;
    }
    tail2->next=head2;
}
void print()
{
    odd *temp=head;
    even *temp2=head2;
    do
    {
        printf("%d ",temp2->data);
        temp2=temp2->next;
    }while(temp2!=head2);
    printf("\n");
    do
    {
    printf("%d ",temp->data);
    temp=temp->next;
    }while(temp!=head);
    
}
int main()
{
    int n,data;
    scanf("%d",&n);
    if(n<=0)
    {
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<n;i++)
    {
    scanf("%d",&data);
    if(data<0)
    {
        printf("Invalid input");
        return 0;
    }
    if(data%2==0)
    {
        even(data);
    }
    else{
        odd(data);
    }
    }
    print();
}