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

struct node {

????int key;
????struct node *left;
????struct node *right;
????struct node *parent;
};

typedef struct node* Node;
Node root;

Node treeSearch(Node x,int k) {
????if(x == NULL || k == x-> key) 
????????return x;
????if(k < x->key)
????????return treeSearch(x->left,k);
????else return treeSearch(x->right,k );
}

void insert(int k) {

????Node y = NULL;
????Node x = root;
????Node z;?? 

????z = malloc(sizeof(struct node));
????z->key = k;
????z->left = NULL;
????z->right = NULL;

??while(x != NULL) {
????????y = x;
????if(z->key < x->key)
????????x = x->left;

????else x = x->right;
??}
????z->parent = y;

????if(y == NULL)
????????root = z;

????else if(z->key < y->key)
????????y->left = z;

????else
????????y->right = z;

}
??
void inorder(Node u) {

????if(u->left != NULL)
????????inorder(u->left);
????printf(" %d",u->key);
????if(u->right != NULL)?? 
????????inorder(u->right); 
}

void preorder(Node u) {
????printf(" %d",u->key);
????if(u->left != NULL)
????????preorder(u->left);
????if(u->right != NULL)
????????preorder(u->right); 
}

int main(void) {
??????
????int n,i,x;
????char tree[5];

????scanf("%d",&n);

????for(i=0;i<n;i++) {
????scanf("%s",tree);
????if(tree[0] == 'f') {
????????scanf("%d",&x);
????????if(treeSearch(root,x) != NULL){
????????????printf("yes\n");
}
????????else printf("no\n");
????}
????else if(tree[0] == 'i') {
????????scanf("%d",&x);
????????insert(x);
????}
????else if(tree[0] == 'p') {
????????if(root != NULL)???? 
????????????inorder(root);
????????printf("\n");
????????if(root != NULL)
????????????preorder(root);
????????printf("\n");
??}
??}
return 0;
}