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

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

typedef struct node Node;

Node *root,*nil;

void insert(int t){
  Node *x=root,*y=nil,*z;

  z=malloc(sizeof(Node));
  z->key = t;
  z->r=nil;
  z->l=nil;

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

void inorder(Node *q){
  if(q==nil)return;

  inorder(q->l);
  printf(" %d",q->key);
  inorder(q->r);
}
void preorder(Node *q){
  if(q==nil)return;

  printf(" %d",q->key);
  preorder(q->l);
  preorder(q->r);
}

void find(int t){
  Node *aaa=root;

  while(1){
    if(aaa==nil){
      printf("no\n");
      break;
    }
    else if(aaa->key == t){
      printf("yes\n");
      break;
    }
    else if(aaa->key < t){
      aaa = aaa -> r;
    }
    else {
      aaa = aaa-> l;
    }
  }
}

int main(){
  int n,i,j,t;
  char s[10];

  root = nil;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0]=='i'){
      scanf("%d",&t);
      insert(t);
    }
    else if(s[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(s[0]=='f'){
      scanf("%d",&t);
      find(t);
    }
  }
  return 0;
}

