#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

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

typedef struct node *Node;

Node root;

void insert(int key){

    Node z;
    Node y = NIL;
    Node x = root;

    z = malloc(sizeof(struct node));

    z->key = key;
    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 pre(Node z){

    if( z == NIL ){
        return;
    }

    printf(" %d",z->key);
    pre(z->left);
    pre(z->right);

}

void ino(Node z){

    if( z == NIL ){
        return;
    }

    ino(z->left);
    printf(" %d",z->key);    
    ino(z->right);

}

Node find(Node u, int key){

      if( u == NIL || key == u->key ){
          return u;
      }  

      if( key < u->key ){
        return find(u->left,key);
      }else{
        return find(u->right,key);
      }


}


int main(){

    int n;
    int i;
    int key;
    char order[8];

    scanf("%d",&n);

    for( i = 0 ; i < n ; i++ ){
        scanf("%s",order);

        if( order[0] == 'i' ){
            scanf("%d",&key);
            insert(key);
        }else if( order[0] == 'p' ){

            ino(root);
            printf("\n");
            pre(root);
            printf("\n");

        }else if( order[0] == 'f' ){

            scanf("%d",&key);

            if( find(root,key) == NIL ){
                printf("no\n");
            }else{
                printf("yes\n");
            }


        }

    }

    return 0;

}