#include<bits/stdc++.h>
using namespace std;

struct Node{
	int key;
	Node *parent, *left, *right;
};
Node *root, *NIL;
void insert(int x);
void Inorder(Node *u);
void Preorder(Node *u);
bool Find(Node *u, int t);
int main()
{
	int n, t;
	string s;
	cin >> n;
	while(n--){
		cin >> s;
		if(s == "insert"){
			cin >> t;
			insert(t);
		}
		else if(s == "print"){
			Inorder(root);
			printf("\n");
			Preorder(root);
			printf("\n");
		}
		else if(s == "find"){
			cin >> t;
			if(Find(root, t)) printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}
void insert(int t){
	Node *z, *y = NIL, *x = root;
	z = (Node *)malloc(sizeof(Node));//神奇了 ,不加不行？？？？？？ 
	z -> key = t;
	z -> left = NIL;
	z -> right = NIL;
	while(x != NIL){
		y = x;
		if(t < x -> key){
			x = x -> left;
		}
		else x = x -> right;
	}
	z -> parent = y;
	if(y == NIL) root = z;
	else{
		if(t < y -> key) y -> left = z;
		else y -> right = z;
	}
}

void Inorder(Node *u){
	if(u == NIL) return;
	Inorder(u -> left);
	printf(" %d", u -> key);
	Inorder(u -> right);
}

void Preorder(Node *u){
	if(u == NIL) return;
	printf(" %d", u -> key);
	Preorder(u -> left);
	Preorder(u -> right);
}
bool Find(Node *u, int t){
	if(u == NIL) return false;
	if(t == u -> key) return true;
	else if(t > u -> key) return Find(u -> right, t);
	else return Find(u -> left, t);
}







 

### 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<bits/stdc++.h>
using namespace std;

struct Node{
	int key;
	Node *parent, *left, *right;
};
Node *root, *NIL;
void insert(int x);
void Inorder(Node *u);
void Preorder(Node *u);
bool Find(Node *u, int t);
int main()
{
	int n, t;
	string s;
	cin >> n;
	while(n--){
		cin >> s;
		if(s == "insert"){
			cin >> t;
			insert(t);
		}
		else if(s == "print"){
			Inorder(root);
			printf("\n");
			Preorder(root);
			printf("\n");
		}
		else if(s == "find"){
			cin >> t;
			if(Find(root, t)) printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}
void insert(int t){
	Node *z, *y = NIL, *x = root;
	z = (Node *)malloc(sizeof(Node));//神奇了 ,不加不行？？？？？？ 
	z -> key = t;
	z -> left = NIL;
	z -> right = NIL;
	while(x != NIL){
		y = x;
		if(t < x -> key){
			x = x -> left;
		}
		else x = x -> right;
	}
	z -> parent = y;
	if(y == NIL) root = z;
	else{
		if(t < y -> key) y -> left = z;
		else y -> right = z;
	}
}

void Inorder(Node *u){
	if(u == NIL) return;
	Inorder(u -> left);
	printf(" %d", u -> key);
	Inorder(u -> right);
}

void Preorder(Node *u){
	if(u == NIL) return;
	printf(" %d", u -> key);
	Preorder(u -> left);
	Preorder(u -> right);
}
bool Find(Node *u, int t){
	if(u == NIL) return false;
	if(t == u -> key) return true;
	else if(t > u -> key) return Find(u -> right, t);
	else return Find(u -> left, t);
}







 

```