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

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

typedef Node *NodePointer;
NodePointer root = NULL;

NodePointer mNode(){
  NodePointer z = malloc(sizeof(Node));
  z->left = NULL;
  z->right = NULL;
  z->parent = NULL;
  z->key = 0;
  return z;
}

void insert(int key){

  NodePointer z = mNode();
  NodePointer y = NULL;
  NodePointer x = root;
  z->key = key;

  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(NodePointer p){
  if(p != NULL){
    inorder(p->left);
    printf(" %d",p->key);
    inorder(p->right);
  }
}
void preorder(NodePointer x){
  if(x != NULL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}

int find(NodePointer x, int key){

  if(x == NULL) return 0;
  else if(x->key == key) return 1;
  if(key < x->key)  return find(x->left,key);
  else  return find(x->right,key);

}

int main(void){

  int i,n,m,key;
  char str[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",str);

    if(str[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(str[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else{
      scanf("%d",&key);
      m = find(root,key);
      if(m == 1) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

