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

typedef struct node_t {
    int key;
    struct node_t *p;
    struct node_t *l;
    struct node_t *r;
} Node;

Node* nNode(int);
void print(Node *);
void inorder(Node *);
void preorder(Node *);
void insert(int, Node *);
Node* find(int, Node *);
void free_tree(Node *);


int main() {
    int i,n,k;
    char com[10];
    Node *tree_root;
    
    tree_root = nNode(0);
    
    scanf("%d",&n);
    
    for (i=0; i<n; i++) {
        scanf("%s",com);
        
        if(com[0] == 'p') print(tree_root->l);
        else {
            scanf("%d",&k);
            
            if(com[0] == 'i') insert(k, tree_root);
            else if(com[0] == 'f') {
                if(find(k, tree_root) != NULL) printf("yes\n");
                else printf("no\n");
            }
        }
    }
    
    free_tree(tree_root);
    
    return 0;
}


Node* nNode(int key) {
    Node *tmp;
    
    tmp = (Node *)malloc(sizeof(Node));
    if(tmp==NULL) exit(0);
    
    tmp->key = key;
    tmp->p = NULL;
    tmp->l = NULL;
    tmp->r = NULL;
    
    return tmp;
}


void print(Node *root) {
    inorder(root);
    printf("\n");
    
    preorder(root);
    printf("\n");
}


void inorder(Node *node) {
    if(node->l!=NULL) inorder(node->l);
    printf(" %d",node->key);
    if(node->r!=NULL) inorder(node->r);
}


void preorder(Node *node) {
    printf(" %d",node->key);
    if(node->l!=NULL) preorder(node->l);
    if(node->r!=NULL) preorder(node->r);
}


void insert(int k,Node *tree_root) {
    Node *x, *y, *z;
    
    z = nNode(k);
    y = tree_root;
    x = tree_root->l;
    
    while (x!=NULL) {
        y = x;
        if(z->key < x->key) x = x->l;
        else x = x->r;
    }
    
    z->p = y;
    
    if(y==tree_root || z->key<y->key) y->l = z;
    else y->r = z;
}


Node* find(int k,Node *tree_root) {
    Node *x;
    
    x = tree_root->l;
    
    while (x->key!=k) {
        if(x->key>k) {
            if(x->l==NULL) return NULL;
            x = x->l;
        }
        else {
            if(x->r==NULL) return NULL;
            x = x->r;
        }
    }
    
    return x;
}


void free_tree(Node *root) {
    if(root->l != NULL) free_tree(root->l);
    if(root->r != NULL) free_tree(root->r);
    free(root);
}