#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
    int data;
    struct node *next;
    
}Node;
Node* create(int data)
{
    Node *newnode=(Node*)malloc(sizeof(Node));
    newnode->data=data;
    newnode->next=NULL;
    return newnode;
}
Node* circular(int arr[],int n)
{
    if(n=0)return NULL;
    Node *head=create(arr[0]);
    Node *temp=head;
    for(int i=1;i<n;i++)
    {
        temp->next=create(arr[i]);
        temp=temp->next;
    }
    temp->next=head;
    return head;
}
void display(Node* head)
{
    if(head==NULL)return;
    Node *temp=head;
    do
    {
        printf("%d",temp->data);
        temp=temp->next;
    }
    while(temp!=head);
    printf("\n");
}
void splitevenodd(Node *head,Node **evenhead,Node **oddhead)
{
    if(head==NULL)return;
    Node *temp=head;
    Node *eventail=NULL,*oddtail=NULL;
    do
    {
        if(temp->data%2==0)
        {
            Node *newnode=create(temp->data);
            if(*evenhead==NULL)
                *evenhead=eventail=newnode;
            else
            {
                eventail->next=newnode;
                eventail=newnode;
            }
        }
        else
        {
            Node *newnode=create(temp->data);
            if(*oddhead==NULL)
            {
                *oddhead=oddtail=newnode;
                
            }
            else
            {
                oddtail->next=newnode;
                oddtail=newnode;
            }
        }
        temp=temp->next;
    }
    while(temp!=head)
    if(eventail!=NULL)eventail->next=*evenhead;
    if(oddtail!=NULL)oddtail->next=*evenhead;
    
}
int main()
{
    int n;
    scanf("%d",&n);
    if(n<0)
    {
        printf("Invalid input");
        return 0;
    }
    int arr[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        if(arr[i]<0)
        {
            printf("Invalid inpput");
            return 0;
        }
    }
    Node *head=create(arr,n);
    Node *evenhead=NULL,*oddhead=NULL;
    splitevenodd(head,&evenhead,&oddhead);
    if(evenhead!=NULL)
      display(evenhead);
    else
     printf("\n");
    if(oddhead!=NULL)
      display(oddhead);
    else
      print("\n");
    return 0;
}