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


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

struct node *root,*NIL;

struct node * search(struct node *a,int k){
while(a!=NIL&&k!=a->key){
  if(k<a->key)a=a->left;
  else a=a->right;
}
return a;
}

void insert(int k){
struct node *y=NIL;
struct node *x=root;
struct node *z;
z=malloc(sizeof(struct node));
z->key = k;

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

    else y->right=z;
    }
  }



void inorder(struct node *z){
  if(z==NIL)return;
  inorder(z->left);
  printf(" %d",z->key);
  inorder(z->right);
}
void preorder(struct node *z){
if(z==NIL) return;
printf(" %d",z->key);
preorder(z->left);
preorder(z->right);
}

int main(){
  int i,n,x;
  char str[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(str[0]=='f'){
      scanf("%d",&x);
      struct node *t=search(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
      }
    else if(strcmp(str,"insert")==0){
        scanf("%d",&x);
        insert(x);
      }
    else if(strcmp(str,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
return 0;
}

