#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL

struct node{
  int key;
  struct node *p,*l,*r;
};

typedef struct node * Node;

Node root;

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

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

void insert(int c){
  Node z,y,x;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = c;
  z->l = NIL;
  z->r = NIL;

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

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

Node find(Node x,int f){
  while(x != NIL && f != x->key){
    if (f < x->key) x = x->l;
    else x = x->r;
  }
  return x;
}

int main(){
  int n,c,f;
  char word[7];
  int i;
  Node t;

  scanf("%d",&n);

  for (i=0; i<n; i++){
    scanf("%s",word);
    if (strcmp(word,"insert") == 0){
      scanf("%d",&c);
      insert(c);
    }
    else if (strcmp(word,"print") == 0){
      in(root);
      printf("\n");
      pre(root);
      printf("\n");
    }
    else if (strcmp(word,"find") == 0){
      scanf("%d",&f);
      t = find(root,f);
      if (t == NIL) printf("no\n");
      else if (t->key == f) printf("yes\n");
    }
  }

  return 0;
}
