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

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

typedef struct Node * NodePointer;


void insert(NodePointer,int);
void search(NodePointer,int);
void preorder(NodePointer);
void inorder(NodePointer);
void postorder(NodePointer);


int main ()
{
  int a,b;
  int i;
  char input[8];

  NodePointer tree = (NodePointer) malloc (sizeof(struct Node));

  
  scanf("%d\n",&a); 
	
  for (i = 0; i  < a; i++){
    scanf("%s" ,&input);
		
    if ( strcmp( input , "insert") == 0 ){
      scanf("%d\n",&b);
      
      if ( i == 0)
	{
	  tree -> key = b;
	  tree -> right = NULL;
	  tree -> left = NULL;
	}  
      else {insert(tree , b);
      }
    }
    else if ( strcmp( input , "find") == 0 ){
      scanf("%d\n",&b);
      search( tree , b);
    }
    else {
      inorder(tree);
      printf("\n");
			
      preorder(tree);
      printf("\n");
    }
  }	
	
  return 0;
}


void insert(NodePointer s,int t)
{
  NodePointer x;
  
  if ( s -> key <= t){
    if  ( s -> right  == NULL){
      x =  (NodePointer) malloc (sizeof(struct Node));
      x -> key = t;
      x -> right = NULL;
      x -> left = NULL;
      s -> right = x;
    }
    
    else {
      insert ( s -> right , t);
    }
	
  }
  else {
    if  ( s -> left  == NULL){
      x =  (NodePointer) malloc (sizeof(struct Node));
      x -> key = t;
      x -> right = NULL;
      x -> left = NULL;
      s -> left = x;
    }
    else {
      insert ( s -> left , t);
    }
  }
}


void search(NodePointer s,int tag)
{
  int flag = 0;
  
  while (s != NULL){
    if (s -> key == tag){flag = 1; break;}
    
    else if (s -> key >= tag){
      s = s -> left;
    }
    else {
      s = s -> right;
    }
  }
  
  if (flag == 0 ){ printf("no\n");
  }
  else if (flag == 1){printf("yes\n");}
}


void preorder ( NodePointer s)
{
  if (s == NULL){return;}
  
  printf(" %d",s->key);
  preorder(s -> left);
  preorder(s -> right);
}


void inorder (NodePointer s)
{
  if (s == NULL){return;}
  
  inorder(s ->left);
  printf(" %d",s->key);
  inorder(s->right);
}


void postorder (NodePointer s)
{
  if (s == NULL){return;}
  
  postorder(s->left);
  postorder(s->right);
  printf(" %d",s->key);
}

