#include<stdio.h>
#include<stdlib.h>
struct node{
    int data;
    struct node* left;
    struct node*right;
};
struct node* create(int x){
    struct node* newnode= (struct node*)malloc(sizeof(struct node));
    newnode->data=x;
    newnode->left = newnode-> right= NULL;
}
struct node* insert(struct node* root, int x){
    if(root==NULL)
        return create(x);
    if(x< root->data)
    root->left= insert(root->data,x);
    else if(x> root->data)
    root->right= insert(root->data,x);
    return root;
}
struct node* delete(struct node* root, int key){
    if(root==NULL)
        return NULL;
    
    if(key<root->data)
    root->left= delete(root->left,key);
    else if(key>root->right)
    root->right= delete(root->right,key);
    else{
        if(root->left=NULL){
            struct node* temp =root->right;
            free(root);
            return temp;
        }
        struct node* temp= min(root->right);
        root->data= temp->data;
        root->right= delete(root->right,temp->data);
    }
    return root;
}
void pre(struct node*root){
    if(root!=NULL){
        printf("%d ",root->data);
        pre(root->left);
        pre(root->right);
    }
}
int valid(int  n){
    return(n>= && n<=20);
}
int main(){
    int n,a;
    if(scanf("%d %d", &n,&a) !=2 || !valid(n)){
        printf("invalid input");
        return 0;
    }
    root =insert(root,a);
    pre("root");
    printf("\n");
    return 0;
}


    
}