// editor5
#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
    int data;
    struct Node*next;
}node;

node*head=NULL;
void insert(int num){
    node*newnode=(node*)malloc(sizeof(node));
    newnode->data=num;
    if(head==NULL){
        newnode->next=newnode;
        head=newnode;
    }
    else{
        newnode->next=head->next;
        head->next=newnode;
    }
}
void display(){
    node *temp=head->next;
    do{
        if(temp->data%2==0)
            printf("%d",temp->data);
            temp=temp->next;
        }while(temp!=head->next);
        
   printf("\n");
   
    do{
        if(temp->data%2!=0){
            printf("%d",temp->data);
            temp=temp->next;
        }
    }while(temp!=head->next);
    
}
int main(){
    int size,num,itr;
    scanf("%d",&size);
    if(size<0){
        pritnf("Invalid input");
        return 0;
    }
    for(int i=1;i<=size;i++){
        scanf("%d",&num);
        insert(num);
    }
    int val;
    scanf("%d",&val);
    insert(val);
    display;
    return 0;

}