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

struct Node{
  int s;
  struct Node *ri;
  struct Node *le;
  struct Node *oya;
};

struct Node *root, *NIL;

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

void Insert(int n){
struct  Node *p = root;
struct  Node *q = NIL;
struct  Node *r;

r = (struct Node *)malloc(sizeof(struct Node));
r -> s = n;
r -> le = NIL;
r -> ri = NIL;

while(p != NIL){
   q = p;
   if(r->s < p->s){
     p = p -> le;
   }
   else{
     p = p -> ri;
   }
}

r -> oya = q;
  if(q == NIL){
    root = r;
  }
  else{
    if(r->s < q->s){
      q -> le = r;
    }
    else{
      q -> ri = r;
    }
  }
}


int main(){
  int i,n,value,findnum;
  char C1[10];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%s",C1);

    if(strcmp(C1,"insert") == 0){
     scanf("%d",&value);
      Insert(value);
    }
    else if(strcmp(C1,"print") == 0){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
    else if(strcmp(C1,"find") == 0){
      scanf("%d",&findnum);
      struct Node *F = Find(root,findnum);
      if(F != NIL) printf("yes\n");
      else printf("no\n");
    }
  }

    return 0;
}



void Inorder(struct Node *a){
  if(a == NIL) return;
  Inorder(a -> le);
  printf(" %d",a -> s);
  Inorder(a -> ri);
}

void Preorder(struct Node *a){
  if(a == NIL) return;
  printf(" %d",a -> s);
  Preorder(a -> le);
  Preorder(a -> ri);
}

struct Node * Find(struct Node *a, int n){
  while(a != NIL && n != a -> s){
    if(n < a -> s ) a = a -> le;
    else a = a -> ri;
  }
  return a;
}

