// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<new>

#include<cstdlib>

#include<cstring>

using namespace std;

typedef struct node;

typedef node * tree;

int bianliang=0;

struct node

{

       int data;

       tree lchild,rchild;

};

tree root;

void build(tree &p,int n)

{

     if(p)

     {

          if(n<p->data)

          build(p->lchild,n);

          if(n>p->data)

          build(p->rchild,n);

     }

     else

     {

         p=new node;

         p->data=n;

         p->lchild=NULL;

         p->rchild=NULL;

     }

}    

void find(tree w,int x)

{

     if(w==NULL)bianliang=-1;

     else if(x==w->data)

       bianliang=1;

     else if(x<w->data)

       find(w->lchild,x);

     else if(x>w->data)

       find(w->rchild,x);

}

void beforeorder(tree q)

{

   if(q==NULL)return;

     cout<<" "<<q->data;

     beforeorder(q->lchild);

     beforeorder(q->rchild);

}

void midorder(tree q)

{

     if(q==NULL)return;

       midorder(q->lchild);

       cout<<" "<<q->data;

       midorder(q->rchild);    

}

int main()

{

    int num;

    cin>>num;

    root=NULL;

    for(int i=1;i<=num;i++)

    {  

       string order;

       cin>>order;

       if(order=="insert")

       {

            int leaf;

            cin>>leaf;

            build(root,leaf);

       }

       else if(order=="find")

       {

            int puzzle;

            cin>>puzzle;

            find(root,puzzle);

            if(bianliang==1)cout<<"yes"<<endl;

            else if(bianliang==-1)cout<<"no"<<endl;

       }

       else if(order=="print")

       {

            midorder(root);

            cout<<endl;

            beforeorder(root);

            cout<<endl;

       } 

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.175221141353194x):
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<ctime>

#define MAXN 500000

struct node

{

	int key;

	node *ch[2];

};

node tree[MAXN+5];

node *Root,*NIL,*ncnt;

//bool first=true;

void Init()

{

	NIL=&tree[0];

	ncnt=&tree[1];

	Root=NIL;

}

inline node *NewNode(int val)

{

	node *p=++ncnt;

	p->key=val;

	p->ch[0]=p->ch[1]=NIL;

	return p;

}

void Insert(node *&rt,int val)

{

	if(rt==NIL)

	{

		rt=NewNode(val);

		return;

	}

	int d=(val>=rt->key);

	Insert(rt->ch[d],val);

}

void PreOrder(node *&rt)

{

	if(rt==NIL)

		return;

//	if(first==true)

//		printf("%d",rt->key),first=false;

//	else

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

	PreOrder(rt->ch[0]);

	PreOrder(rt->ch[1]);

}

void InOrder(node *&rt)

{

	if(rt==NIL)

		return;

	InOrder(rt->ch[0]);

//	if(first==true)

//		printf("%d",rt->key),first=false;

//	else

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

	InOrder(rt->ch[1]);

}

node *Find(node *rt,int val)

{

	if(rt==NIL)

		return NIL;

	if(rt->key==val)

		return rt;

	int d=(val>rt->key);

	return Find(rt->ch[d],val);

}

int main()

{

	Init();

	int n,x;

	char op[100];

	scanf("%d",&n);

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

	{

		scanf("%s",op);

		if(op[0]=='i')

			scanf("%d",&x),Insert(Root,x);

		else if(op[0]=='p')

		{

			InOrder(Root);

			printf("\n");

			PreOrder(Root);

			printf("\n");

		}

		else if(op[0]=='f')

		{

			scanf("%d",&x);

			if(Find(Root,x)==NIL)

				printf("no\n");

			else

				printf("yes\n");

		}

	}

	return 0;

}