// Original C++ solution (slower):
#include<bits/stdc++.h>



#define ms(a,x) memset(a,x,sizeof(a))

using namespace std;



typedef long long ll;

struct pp{

	int key;

	pp *l, *r, *p; 

};



pp *root , *NIL;

pp * find(pp *x,int k){

	while(x != NIL &&k != x->key){

		if(k < x->key)

			x = x->l;

		else 

			x = x->r;

	}

	return x;

}



void insert (int k){

	pp *y=NIL;

	pp *x=root;

	pp *z;

	z = (pp *)malloc(sizeof(pp));

	

	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(pp *x){

	if(x == NIL) return ;

	in(x->l);

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

	in(x->r);

}



void pr(pp *x){

	if(x == NIL) return ;

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

	pr(x->l);

	pr(x->r);

}

int main(){

	int n,x;

	string com;

	cin >> n;

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

		cin>>com;

		if(com[0] == 'f'){

			scanf("%d", &x);

			pp *t= find(root ,x );

			if(t != NIL)cout<<"yes\n";

			else printf("no\n");

		} 

		else if(com == "insert"){

			scanf("%d", &x);

			insert(x);

		}

		else if(com == "print"){

			in(root);

			cout<<endl;

			pr(root);

			cout<<endl;

		}

	}

	return 0;

}






// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <stdlib.h>

typedef struct Node{

    int data;

    struct Node *parent, *left, *right;

}Node;

Node *root;

void insert(int x){

    Node *t = (Node *)malloc(sizeof(Node));

    t->data = x;

    t->left = t->right = t->parent = NULL;



    if(root == NULL){

        root = t;

    }else{

        Node *child = root;

        Node *parent = NULL;

        while(child != NULL){

            parent = child;

            if(x < child->data){

                child = child->left;

            }

            else{

                child = child->right;

            }

        }

        t->parent = parent;

        if(x < parent->data){

            parent->left = t;

        }else{

            parent->right = t;

        }

    }

}

void Preorder(Node *t){

    if(t == NULL) return ;

    printf(" %d", t->data);

    Preorder(t->left);

    Preorder(t->right);

}

void Inorder(Node *t){

    if(t == NULL) return ;

    Inorder(t->left);

    printf(" %d", t->data);

    Inorder(t->right);

}

void find(int b){

    Node *temp = root;

    while(temp != NULL){

        if(temp->data == b){

            printf("yes\n");

            return ;

        }

        if(b < temp->data){

            temp = temp->left;

        }

        else{

            temp = temp->right;

        }

    }

    printf("no\n");

}

int main(){

    root = NULL;

    int n;

    scanf("%d", &n);

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

        char a[10]; int b;

        scanf("%s", a);

        if(a[0] == 'i'){

            scanf("%d", &b);

            insert(b);

        }

        else if(a[0] == 'p'){

            Inorder(root);

            printf("\n");

            Preorder(root);

            printf("\n");

        }

        else if(a[0] == 'f'){

            int c;

            scanf("%d", &c);

            find(c);

        }

    }

    return 0;

}


// Fastest known solution for this problem: