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

#define NIL -1
#define TRUE 1
#define FALSE 0
#define MAX 500000

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

void insert(int);
int find(int, int);
void inorder(int);
void preorder(int);

int root=-1;
node T[MAX];

int main(){
  int n, num,  i;
  char command[10];

  scanf("%d", &n);

  for( i=0 ; i<n ; i++ ){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
    
  for( i=0 ; i<n ; i++ ){
    scanf("%s",command);
    
    if(strcmp(command, "insert") == 0){
      scanf("%d",&T[i].key);
      insert(i);
    }
    else if(strcmp(command, "find") == 0){
      scanf("%d",&num);
      if(find(0, num) == TRUE) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(command, "print") == 0){
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }

  return 0;
}

void insert(int z){
  int x = root;
  int y = NIL;
  
  while(x != NIL){
    y = x;
    
    if(T[z].key < T[x].key){
      x = T[x].left;
    }
    else{
      x = T[x].right;
    }
  }
  T[z].parent = y;

  //T???????????´???
  if(y == NIL){
    root = z;
  }
  else if(T[z].key < T[y].key){
    T[y].left = z;
  }
  else{
    T[y].right = z;
  }
}

int find(int x, int key){
  if(T[x].key = key) return TRUE;
  if( key<T[x].key && T[x].left!=NIL ){
    return find(T[x].left, key);
  }
  if( key>T[x].right && T[x].right!=NIL ){
    return find(T[x].right, key);
  }
  return FALSE;
}

void inorder(int x){
  if(x != NIL){
    inorder(T[x].left);
    printf(" %d", T[x].key);
    inorder(T[x].right);
  }
}

void preorder(int x){
  if(x != NIL){
    printf(" %d", T[x].key);
    preorder(T[x].left);
    preorder(T[x].right);
  }
}