#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define N 500001
#define NIL NULL

struct node{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};

typedef struct node *Node;

Node root;

void insert(int k){
    Node z;
    Node y=NIL;
    Node x=root;

    z=malloc(sizeof(struct node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key < x->key) x=x->left;
        else x=x->right;
    }

    z->parent=y;

    if(y==NIL) root=z;
    else if(z->key < y->key) y->left=z;
    else y->right=z;
}

void Preorder(Node u){
    if(u!=NIL){
    printf(" %d",u->key);
    if(u->left != NIL) Preorder(u->left);
    if(u->right != NIL) Preorder(u->right);
    }
}

void Inorder(Node u){
    if(u!=NIL){
        Inorder(u->left);
        printf(" %d",u->key);
        Inorder(u->right);
    }
}

Node find(Node r, int k){
    if(r == NIL || k == r->key) return r; 
    if(k < r->key) return find(r->left,k);
    else if(k > r->key) return find(r->right,k);
}

int main ()
{
    int n,i,x;
    char s[10];

    scanf("%d",&n);


    for(i=0;i<n;i++){
        scanf("%s",s);
        if(strcmp(s,"insert")==0){
            scanf("%d",&x);
            insert(x);
        }
        else if(strcmp(s,"find")==0){
            scanf("%d",&x);
            if(find(root,x)!=NIL) printf("yes\n");
            else printf("no\n");
        }
        else if(strcmp(s,"print")==0){
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }

    return 0;
}