#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef struct d{ll n,r,l;}d;
const ll INF=100000000000000000;
d T[1000001];
int N,gp=1;

void pre(int n)
{
	if(n==-1)return;
	printf(" %d",T[n].n);
	if(T[n].l!=-1)pre(T[n].l);
	if(T[n].r!=-1)pre(T[n].r);
	return;
}

void ino(int n)
{
	if(n==-1)return;
	if(T[n].l!=-1)ino(T[n].l);
	printf(" %d",T[n].n);
	if(T[n].r!=-1)ino(T[n].r);
	return;
}

void ins(int p,int np=0)
{
	if(T[np].n==INF)T[np].n=p;
	else
	{
		if(T[np].n>p)
		{
			if(T[np].l==-1)
				T[np].l=gp++;
			ins(p,T[np].l);
		}
		else
		{
			if(T[np].r==-1)
				T[np].r=gp++;
			ins(p,T[np].r);
		}
	}
}

void p()
{
	ino(0);puts("");
	pre(0);puts("");
}

bool f(int p,int np=0)
{
	if(T[np].n==p)return 1;
	if(T[np].r!=-1&&T[np].n<p)
		return f(p,T[np].r);
	if(T[np].l!=-1&&T[np].n>p)
		return f(p,T[np].l);
	return 0;
}

int main()
{
	for(int i=0;i<1000001;i++)
	{
		T[i].n=INF;
		T[i].r=T[i].l=-1;
	}
	scanf("%d\n",&N);
	for(int i=0;i<N;i++)
	{
		char s[20];
		int a;
		scanf("%s%d\n",s,&a);
		if(s[0]=='i')
			ins(a);
		else if(s[0]=='f')
			puts(f(a)?"yes":"no");
		else
			p();
	}
}
### Prompt

Your challenge is to write a CPP solution to the following problem:

Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.

* insert  $k$: Insert a node containing $k$ as key into $T$.
* find $k$: Report whether $T$ has a node containing $k$.
* print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.

Constraints

* The number of operations $\leq 500,000$
* The number of print operations $\leq 10$.
* $-2,000,000,000 \leq key \leq 2,000,000,000$
* The height of the binary tree does not exceed 100 if you employ the above pseudo code.
* The keys in the binary search tree are all different.

Input

In the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$ or print are given.

Output

For each find $k$ operation, print "yes" if $T$ has a node containing $k$, "no" if not.

In addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.

Example

Input

10
insert 30
insert 88
insert 12
insert 1
insert 20
find 12
insert 17
insert 25
find 16
print


Output

yes
no
 1 12 17 20 25 30 88
 30 12 1 20 17 25 88

### Response

```cpp
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef struct d{ll n,r,l;}d;
const ll INF=100000000000000000;
d T[1000001];
int N,gp=1;

void pre(int n)
{
	if(n==-1)return;
	printf(" %d",T[n].n);
	if(T[n].l!=-1)pre(T[n].l);
	if(T[n].r!=-1)pre(T[n].r);
	return;
}

void ino(int n)
{
	if(n==-1)return;
	if(T[n].l!=-1)ino(T[n].l);
	printf(" %d",T[n].n);
	if(T[n].r!=-1)ino(T[n].r);
	return;
}

void ins(int p,int np=0)
{
	if(T[np].n==INF)T[np].n=p;
	else
	{
		if(T[np].n>p)
		{
			if(T[np].l==-1)
				T[np].l=gp++;
			ins(p,T[np].l);
		}
		else
		{
			if(T[np].r==-1)
				T[np].r=gp++;
			ins(p,T[np].r);
		}
	}
}

void p()
{
	ino(0);puts("");
	pre(0);puts("");
}

bool f(int p,int np=0)
{
	if(T[np].n==p)return 1;
	if(T[np].r!=-1&&T[np].n<p)
		return f(p,T[np].r);
	if(T[np].l!=-1&&T[np].n>p)
		return f(p,T[np].l);
	return 0;
}

int main()
{
	for(int i=0;i<1000001;i++)
	{
		T[i].n=INF;
		T[i].r=T[i].l=-1;
	}
	scanf("%d\n",&N);
	for(int i=0;i<N;i++)
	{
		char s[20];
		int a;
		scanf("%s%d\n",s,&a);
		if(s[0]=='i')
			ins(a);
		else if(s[0]=='f')
			puts(f(a)?"yes":"no");
		else
			p();
	}
}
```