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

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

typedef struct node *Tree;

#define NILL NULL

Tree tree;Tree 

TreeSearch(Tree n,int k){
  if(n == NILL || k == n->key){
    return n;
  }
  if(k < n->key){
    return TreeSearch(n->left,k);
  }
  else{
    return TreeSearch(n->right,k);
  }
}

void TreeInsert(int k){
  Tree m = NILL;
  Tree l = tree;
  Tree n;

  n = malloc(sizeof(struct node));
  n->key = k;
  n->left = NILL;
  n->right = NILL;

  while(l != NILL){
    m = l;
    if(n->key < l->key){
      l = l->left;
    }
    else{
      l = l->right;
    }
  }
  n->parent = m;
  
  if(m == NILL){
    tree = n;
  }
  else if(n->key < m->key){
    m->left = n;
  }
  else{
    m->right = n;
  }
}

void TreePreorder(Tree n){
  if(n != NILL){
    printf(" %d",n->key); 
    TreePreorder(n->left);
    TreePreorder(n->right);
  }
}

void TreeInorder(Tree n){
  if(n != NILL){
    TreeInorder(n->left);
    printf(" %d",n->key);
    TreeInorder(n->right);
  }
}

int main(){
  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);
      TreeInsert(j);
    }
    else if(command[0] == 'p'){
      TreeInorder(tree);
      printf("\n");
      TreePreorder(tree);
      printf("\n");
    }
    else if(command[0] == 'f'){
      scanf("%d", &j);
      Tree temp = TreeSearch(tree,j);
      if(temp != NILL)printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}