#include<stdio.h>
#include <stdlib.h>
#define NIL NULL
struct Node{
  int key;
  struct Node *p,*l,*r;
};

 struct Node* root;

void insert(int);
void inorder(struct Node*);
void preorder(struct Node*);
struct Node* find(struct Node*,int);
int main(){
  int m,x;
  int i,j=0,c=0;
  char k[10];

  scanf("%d",&m);
  for(i=0; i < m; i++){
    scanf("%s",k);
     if(k[0]=='f'){
      scanf("%d",&x);
      if(find(root,x)!=NIL)
        printf("yes\n");
      else printf("no\n");
     }
     else if(k[0]=='i'){
      scanf("%d",&x);
      insert(x);
     }

     else if(k[0]=='p'){
      if(root !=NIL)
      inorder(root);
      printf("\n");
      if(root!=NIL)
      preorder(root);
      printf("\n");
       }
       }

  return 0;
  }


void insert(int a){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=malloc(sizeof(struct Node));
  z->key=a;
  z->l=NIL;
  z->r=NIL;

      if(find(root,x)!=NIL)
        printf("yes\n");
      else printf("no\n");
     }
     else if(k[0]=='i'){
      scanf("%d",&x);
      insert(x);
     }

     else if(k[0]=='p'){
      if(root !=NIL)
      inorder(root);
      printf("\n");
      if(root!=NIL)
    preorder(root);
      printf("\n");
       }
       }

  return 0;
  }


void insert(int a){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=malloc(sizeof(struct Node));
  z->key=a;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->l;
    else x=x->r;
  }
  z->p=y;

  if(y==NIL) root=z;
  else if(z->key < y->key){
      y->l=z;
    }
  else y->r =z;

}

void inorder(struct Node *x){
  if(x == NIL) return;
  inorder(x->l);
  printf(" %d",x->key);
 inorder(x->r);
}

void preorder(struct Node *x){
  if(x==NIL) return;
  printf(" %d",x->key);
  preorder(x->l);
  preorder(x->r);
}

struct Node* find(struct Node *x,int k){
  while(x !=NIL && k !=x->key){
    if(k < x->key) x=x->l;
    else x=x->r;
  }
  return x;
}