#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 search(Node,int);


int main(){

  int n,num,i;
  char command[10];

  scanf("%d",&n);

  root = NULL;
  for(i = 0 ; i < n ; i++){

    scanf("%s",command);

    if(command[0] == 'i'){//insert
      scanf("%d",&num);
      insert(num);
    }

    else if(command[0] == 'p'){//print
      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");
    }
    else if(command[0] == 'f'){//find
      scanf("%d",&num);

      Node test = search(root,num);
      if(test != NULL)printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}


void insert( int z){

  Node y = NULL;
  Node x = root;
  Node k;

  k = malloc(sizeof(struct node));

  k -> key = z;
  k -> left = NULL;
  k -> right = NULL;


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


void inorder (Node o){
  if(o->left != NULL)inorder(o->left);
  printf(" %d",o->key);

  if(o->right != NULL)inorder(o->right);
}




void preorder(Node o){
  printf(" %d",o->key);

  if(o->left != NULL)preorder(o->left);
  if(o->right != NULL)preorder(o->right);
}


int search (Node u,int k){
  if(u == NULL || k ==  u->key)return u;
  if(k < u->key)return search(u->left,k);
  else return search(u->right,k);
}