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

struct node{
  int me;
  struct node *parent,*left,*right;
};
typedef struct node *point;
point root;
void insert(int);
void list(point);
void list1(point);
int find(int,point);

int main(){
  int x,i,num1,num2;
  char com[8];
  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%s",com);
    if((strcmp(com,"insert"))==0){
      scanf("%d",&num1);
      insert(num1);
    }
    else if((strcmp(com,"find"))==0){
      scanf("%d",&num1);
      num2=find(num1,root);
      if(num2==1)printf("yes\n");
      else printf("no\n");
    }
    else{
      list(root);
      printf("\n");
      list1(root);
      printf("\n");
    }
  }
  return 0;
}
void insert(int id){
  point x,y,z;
  z=malloc(sizeof(struct node));
  z->me=id;
  z->right=NULL;
  z->left=NULL;
  y=NULL;
  x=root;
  while(x!=NULL){
    y=x;
    if(z->me < x->me)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if(y==NULL)
    root = z;
  else if(z->me < y->me)
    y->left = z;
  else
    y->right = z;
}
void list(point x){
  if(x!=NULL){
    list(x->left);
    printf(" %d",x->me);
    list(x->right);
  }
}
void list1(point x){
  if(x!=NULL){
    printf(" %d",x->me);
    list1(x->left);
    list1(x->right);
  }
}
int find(int num,point x){
  while(x!=NULL&&num!=x->me){
    if(num<x->me)x=x->left;
    else x=x->right;
  }
  if(x!=NULL)return 1;
  return 0;
}
    
  

