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

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

typedef struct node * Node;
Node root;

Node find(Node u,int k) {
if( u == NIL || k == u->key) {
		return u;
	}
	else if(k < u->key) {
		return find(u->l,k);
	}
	else return find(u->r,k);
}

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = 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 in(Node u) {
  if(u->l != NIL) {
	  in(u->l);
	}
	printf(" %2d", u->key);
	if(u->r != NIL) {
	  in(u->r);
	}
}

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

int main() {
  
  int n, i, x;
  char s[20];
  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%s",s);
    
    if(s[0] == 'f') {
	    scanf("%d",&x);
	    Node t = find(root, x);
	    printf("\n");
	    if(t != NIL) printf("yes\n");
	    else printf("No\n");
    }

    else if(s[0] =='i') {
      scanf("%d",&x);
      insert(x);
    }

    else if(s[0] == 'p') {
      in(root);
      printf("\n");
      pre(root);
      printf("\n");
    }
  }
  return 0;
}