#include <stdio.h>
#include <stdlib.h>
struct N{
  struct N *oya;
  struct N *left;
  struct N *right;
  int key;
};
typedef struct N * NODE;
NODE root;

NODE find(NODE d,int k){
  while(d!=NULL && k!=d->key){
    if(d->key > k){
      d=d->left;
    }
    else {
      d=d->right;
    }
  }
  return d;
}


void Ins(int ke){
  NODE y=NULL;
  NODE x=root;
  NODE z;
  z=malloc(sizeof(struct N));
  z->left=NULL;
  z->right=NULL;
  z->key=ke;

  while(x!=NULL){
    y=x;
    if(x->key > z->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }

  z->oya=y;

  if(y==NULL){
    root=z;
  }
  else if(y->key > z->key){
    y->left=z;
  }
  else(y->right=z);
}

void preorder(NODE a){
  if(a==NULL)return;
  printf(" %d",a->key);
  preorder(a->left);
  preorder(a->right);
}

void inorder(NODE a){
  if(a==NULL)return;

  inorder(a->left);

  printf(" %d",a->key);

  inorder(a->right);
}


int main(void){
  int i,n,j;
  char c[20];
  scanf("%d",&n);

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

    scanf("%s",c);

    if(c[0]=='i'){
      scanf("%d",&j);
      Ins(j);
    }
    else if(c[0]=='f'){
      scanf("%d",&j);
      NODE e=find(root,j);
      if(e!=NULL)printf("yes\n");
      else printf("no\n");
    }

      
    else if(c[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

