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


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

typedef struct node *Node;
Node root;

void insert(int );
void inorder(Node );
void preorder(Node );
int find(int ,Node );
int main(){
  int n,i;
  int k,m,s;
  char t[5];

  scanf("%d",&n);
  
  for(i=0 ; i<n ; i++){
    scanf("%s",t);
    if(t[0]== 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    if(t[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    if(t[0]=='f'){
      scanf("%d",&s);
      m = find(s,root);
      if(m==0)printf("no\n");
      else printf("yes\n");
    }
  }

  return 0;
}


void insert(int k){
  Node z;
  Node y = NULL;
  Node x = root;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL){//?????????insert??????????????????
    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(Node T){
  if(T != NULL){
    inorder(T->left);
    printf(" %d",T->key);
    inorder(T->right);
  }
}


void preorder(Node T){
  if(T != NULL){
    printf(" %d",T->key);
    preorder(T->left);
    preorder(T->right);
  }
}

int find(int k,Node node){
  if(node == NULL){
    return 0;
  }
  if(node->key == k){
    return 1;
  }
  else if(node->key < k){
    return find(k , node->right);
  }
  else{
    return find(k , node->left);
  }
}