#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define N 200001
#define MAX 1000

struct Node{
    int key;
    struct Node *right,*left,*parent;
};

struct Node *root,*NI;
struct Node *find(struct Node *u,int k){
    while(u != NI && k != u->key){
        if(k < u->key){u=u->left;}
        else{u=u->right;}
    }
    return u;
}

void insert(int k){
    struct Node *y=NI;
    struct Node *x=root;
    struct Node *z;

    z=(struct Node *)malloc(sizeof(struct Node));
    z->key=k;
    z->left=NI;
    z->right=NI;
    while(x != NI){
        y=x;
        if(z->key < x->key){  x=x->left;}
        else{x=x->right;}
    }
    z->parent=y;
    if(y==NI){root=z;}
    else{
        if(z->key < y->key){y->left=z;}
        else{y->right=z;}
    }
}

void inorder(struct Node *u){
    if(u==NI){return;}
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(struct Node *u){
    if(u==NI){return;}
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(void){
    int j,i,x;
    char line[7];
    scanf("%d",&j);
    for(i=0;i<j;i++){
        scanf("%s",line);
        if(!strcmp(line,"insert")){
            scanf("%d",&x);
            insert(x);
        }
        else if(!strcmp(line,"print")){
            inorder(root);
            puts("");
            preorder(root);
            puts("");
        }
        else{
            scanf("%d",&x);
            struct Node *temp=find(root,x);
            if(temp != NI){puts("yes");}
            else {puts("no");}
        }
    }
    return 0;
}

