#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
} ;

int flag = 0;

typedef struct node Node;

Node *root, *NIL;

void Insert(int);
void Inorder(Node *);
void Preorder(Node *);
void Find(Node *, int);

int main(){
  int n,i,a;
  char in[7],insert[7] = "insert",find[5] = "find",print[6] = "print";
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",in);
    (void)getchar();
    if(strcmp(in, insert) == 0) {
      scanf(" %d",&a);
      Insert(a);
    }
    else if(strcmp(find, in) == 0) {
      scanf("%d",&a);
      Find(root,a);
      if(flag == 1){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
      flag = 0;
    }
    else  {
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}
void Insert(int a) {
  Node *x = NIL;
  Node *y = root;
  Node *z;

  z = malloc(sizeof(Node));
  z -> key = a;
  z -> l = NIL;
  z -> r = NIL;
  while(y != NIL) {
    x = y;
    if(z -> key < y -> key){
      y = y -> l;
    }
    else{
      y = y -> r;
    }
  }

  z -> p = x;
  if(x == NIL){
    root = z;
  }
  else {
    if(z -> key < x -> key){
      x -> l = z;
    }
    else{
      x -> r = z;
    }
  }
}

void Inorder(Node *u) {
  if(u == NIL){
    return;
  }
  else {
    Inorder(u -> l);
    printf(" %d", u->key);
    Inorder(u -> r);
  }
}

void Preorder(Node *b) {
  if(b == NIL){
    return;
  }
  else {
    printf(" %d", b->key);
    Preorder(b -> l);
    Preorder(b -> r);
  }
}
void Find(Node *b, int c) {
    if(b == NIL){
      return;
    }
  else {
    if(b -> key == c) {
      flag = 1;
      return;
    }
  }
    if(b -> key > c) {
      Find(b -> l, c);
      return;
    }
    else {
      Find(b -> r, c);
      return;
    }
}

