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

int n;
int i,j;


int x;
int count=0;
int cnt[10];
int tmp=0;
char *comi = "insert";
char *comp = "print";


struct Node{
  int k;

  
  struct Node *r;
  struct Node *l;
  struct Node *p;
};

struct Node *root;
struct Node *NIL;






void insert(int key){

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

  z = (struct Node*)malloc(sizeof(struct Node));

  z->k=key;
  z->l=NIL;
  z->r=NIL;

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



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

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



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


int main(){



  struct Node *t;
  char *com;


  com = (char*)malloc(7*sizeof(char));  

  scanf("%d", &n);



  
  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0] == 'f'){
      scanf("%d", &x);
      t = find(root, x);

      
      if(t != NIL){
	printf("yes\n");
      }

      
      else{
	printf("no\n");
      }
    }




    
      else if(strncmp(com,comi,6)==0){
	scanf("%d",&x);
	insert(x);
      }
      else if(strncmp(com,comp,5)==0){

	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    }

    return 0;
  }

