#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *left,*right;
}node;

node *root=NULL;

int isempty(){
    
}
node *create(int num){
    node *newnode=(node*)malloc(1*sizeof(node));
    newnode->data=num;
    newnode->left=NULL;
    newnode->right=NULL;
    return newnode;
}

node *insert(int *root,int num){
    if(root==NULL){
        return root;
    }
    if(num<root->data){
        root->left=insert(root->left,num);
    }
    else if(num>root->data){
        root->right=insert(root->right,num);
    }
}
void preorder(struct node* root){
    if(root==NULL)return;
    printf("%d",root->data);
    preorder(root->left);
    preorder(root->right);
}
void inorder(struct node* root){
    if(root==NULL)return;
    inorder(root->left);
    printf("%d ",root->data);
    inorder(root->right);
}
void postorder(struct node* root){
    if(root==NULL)return;
    postorder(root->left);
    printf("%d ",root->data);
    postorder(root->right);
}
int main(){
    int num,arr[n],i;
    scanf("%d",&num);
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
    struct node* root=buildtree(arr,n,0);
    preorder(root);
    printf("\n");
    inorder(root);
    printf("\n");
    postorder(root);
    printf("\n");
    return 0;
    }
}