#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL

typedef struct node{
  struct node *parent, *left, *right;
  int key;
}*N;

N root = NIL;

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

int main(){
  int m, i, k;
  char str[256];

  scanf("%d", &m);

  for(i = 0; i < m; i++){
    scanf("%s", str);
    if(strcmp(str, "insert") == 0){
      scanf("%d", &k);
      insert(k);
    }else if(strcmp(str, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(strcmp(str, "find") == 0){
      scanf("%d", &k);
      if(find(root, k) != NIL)   printf("yes\n");
      else                                printf("no\n");
    }  
  }
    
  return 0;
}

void insert(int v){
  N y = NIL, x = root, z;
  
  z = malloc(sizeof(struct node));
  z->key = v;
  z->left = 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)  root = z;
  else if(z->key < y->key)   y->left = z;
  else                                   y->right = z;
}

N find(N u, int k){
  while(u != NIL && k != u->key){
    if(k< u->key)   u = u->left;
    else                  u = u->right;
  }
    return u;
}

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

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