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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * node;

#define NIL NULL

void insert(int);
void inorder(node );
void preorder(node );
node treeSearch(node , int );

node T;

int main(){
  int n;
  char read[8];
  int k;
  int i;
  int x;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    if(scanf("%s",read)==EOF)break;
    if(read[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    if(read[0]=='p'){
      inorder(T);
      printf("\n");
      preorder(T);
      printf("\n");
    }
    if ( read[0] == 'f' ){
      scanf("%d", &x);
      node t = treeSearch(T, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

void insert(int k){

  node y = NIL;
  node x = T;
  node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;


  
 
  y=NIL;
  x=T;
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;

  }
  z->p=y;
  if(y==NIL){
    T=z;
  }
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

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

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

node treeSearch(node u, int k){
  if(u==NIL){
    return u;
  }
  if(u->key==k){
    return u;
  }
  if(u->key>k){
    treeSearch(u->left,k);
  }
  else  treeSearch(u->right,k);
}

