#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *parent;
  struct node *right;
  struct node *left;
  int key;
};
 
typedef struct node *Tree;
 

 
Tree t;Tree
 
Search(Tree n,int k){
  if(n == NULL || k == n->key){
    return n;
  }
  if(k < n->key){
    return Search(n->left,k);
  }
  else{
    return Search(n->right,k);
  }
}
 
void Insert(int k){
  Tree m = NULL;
  Tree l = t;
  Tree n;
 
  n = malloc(sizeof(struct node));
  n->key = k;
  n->left = NULL;
  n->right = NULL;
 
  while(l != NULL){
    m = l;
    if(n->key < l->key){
      l = l->left;
    }
    else{
      l = l->right;
    }
  }
  n->parent = m;
   
  if(m == NULL){
    t = n;
  }
  else if(n->key < m->key){
    m->left = n;
  }
  else{
    m->right = n;
  }
}
 
void Preorder(Tree n){
  if(n != NULL){
    printf(" %d",n->key);
    Preorder(n->left);
    Preorder(n->right);
  }
}
 
void Inorder(Tree n){
  if(n != NULL){
    Inorder(n->left);
    printf(" %d",n->key);
    Inorder(n->right);
  }
}
 
int main(void){
  int n,i,j;
  char command[10];
  scanf("%d",&n);
 
  for(i =0;i < n;i++){
    scanf("%s",command);
    if(command[0] == 'i'){
      scanf("%d",&j);
      Insert(j);
    }
    else if(command[0] == 'p'){
      Inorder(t);
      printf("\n");
      Preorder(t);
      printf("\n");
    }
    else if(command[0] == 'f'){
      scanf("%d", &j);
      Tree temp = Search(t,j);
      if(temp != NULL)printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}