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

int cnt=0;

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

typedef struct node *Nodepointer;

Nodepointer r,NIL;

void insert(int);
void print(void);

void inorder(Nodepointer);
void preorder(Nodepointer);

int find(int);

int main(){
  int i,n,num;
  char c[7];

scanf("%d",&n);
 
for(i=0;i<n;i++){
  scanf("%s",c);
  
  if(c[0]=='i'){
    scanf("%d",&num);
    insert(num);
  }
  else if(c[0]=='f'){
    scanf("%d",&num);
    if(find(num)==0)printf("no\n");
    else printf("yes\n");
  }
  else print();
 }
  return 0;
}

void insert(int k){
  Nodepointer y=NIL;
  Nodepointer x=r;

  Nodepointer z = (Nodepointer)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){
    r = z;
  }

  else if(z->key < y->key){
    y->left = z;
  }

  else{
    y->right = z;
  }

}

void print(void){
    inorder(r);
    printf("\n");
    preorder(r);
    printf("\n");
}

void inorder(Nodepointer a){
  if(a==NIL)return;
  inorder(a->left);
  printf(" %d",a->key);
  inorder(a->right);
}
void preorder(Nodepointer a){
  if(a == NIL){
    return;
  }
  printf(" %d",a->key);
  preorder(a->left);
  preorder(a->right);
}

int find(int k){
 Nodepointer T;
  T=r;
  while(T!=NULL && T->key!=k){
    if(k<T->key)T=T->left;
    else T=T->right;
  }
  
  if(T==NULL)return 0;
  else return 1;
}

