#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 k){
  Node y = NULL;
  Node x = root;
  Node z;

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

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

Node 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);
  }
}



int main(){

  char c[20];
  int n, i, x;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( c[0] == 'f' ){
      scanf("%d", &x);
      Node t = Search(root, x);
      if ( t != NULL ) printf("yes\n");
      else printf("no\n");
    } else if ( c[0] == 'i' ){
      scanf("%d", &x);
      Insert(x);
    } else if ( c[0] == 'p' ){
      Order1(root);
      printf("\n");
      Order2(root);
      printf("\n");
    }
  }

  return 0;
}