#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 500000

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

void insert(int);
void inorder(struct node *);
void preorder(Node *);
int find(int);

int main(){
  int n,i,j,z;
  char com[10],in[] = "insert",pr[] = "print",fi[] = "find";

  scanf("%d",&n);
  root=NULL;
  for(i = 0;i < n;i++){
    scanf("%s",com);
    if(strcmp(com,pr)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(com,in)==0){
      scanf("%d",&z);
      insert(z);
    }
    else{
      scanf("%d",&z);
      if(find(z) == 1) printf("yes\n");
      else printf("no\n");
    }
  }
  
  
  return 0;
}

void insert(int key){
  Node *y = NULL;
  Node *x = root;//y->xの親 x->root
  Node *z;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = key;
  z->left = NULL;
  z->right = NULL;
  
  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(Node *r){
  if(r == NULL) return;
  inorder(r->left);
  printf(" %d",r->key);
  inorder(r->right);
}

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

int find(int z){
  Node *x = root;
  while(1){
  if(z == x->key) return 1;
  else if(z > x->key) x = x->right;
  else x = x->left;
  if(x == NULL) return 0;
  }
}

