#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
struct Node {
	int key;
	Node *l, *r, *p;
};
Node *root, *NIL; 
inline void pre(Node *u) {

	cout << " " << u->key;
	if (u->l != NIL) pre(u->l);
	if (u->r != NIL) pre(u->r);
}
inline void in(Node* u) {
	if(u->l != NIL)in(u->l);
	cout << " " << u->key;
	if (u->r != NIL) in(u->r);

}
inline int find(int k) {
	Node *r = root;
	//Node *f = NIL;
	Node *f;
	f = (Node *)malloc(sizeof(Node));
	f->key = k;
	while (r != NIL) {
		if (k < r->key)
			r = r->l;
		else if(k > r->key) r = r->r;
		else return 1;
	}
	return 0;
}
inline void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	Node *z;
	int cnt = 0;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->l = NIL;
	z->r = NIL;
	while (x != NIL) {
		y = x;
		if (x->key > z->key)
			x = x->l;
		else
			x = x->r;
	}
	z->p = y;
	if (y == NIL) {
		root = z;
	}
	else if (y->key > z->key) {
		y->l = z;
	}
	else if (y->key < z->key) {
		y->r = z;
	}
}
int main(){
	int m;
	cin >> m;
	string com;
	int n;
	for (int i = 0; i < m; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &n);
			insert(n);
		}
		else if(com == "print"){
			in(root);
			cout << endl;
			pre(root);
			cout << endl;
		}
		else {
			scanf("%d", &n);
			if (find(n)) cout << "yes" << endl;
			else cout << "no" << endl;
		}

	}
	return 0;
}
### Prompt

Please formulate 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
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
struct Node {
	int key;
	Node *l, *r, *p;
};
Node *root, *NIL; 
inline void pre(Node *u) {

	cout << " " << u->key;
	if (u->l != NIL) pre(u->l);
	if (u->r != NIL) pre(u->r);
}
inline void in(Node* u) {
	if(u->l != NIL)in(u->l);
	cout << " " << u->key;
	if (u->r != NIL) in(u->r);

}
inline int find(int k) {
	Node *r = root;
	//Node *f = NIL;
	Node *f;
	f = (Node *)malloc(sizeof(Node));
	f->key = k;
	while (r != NIL) {
		if (k < r->key)
			r = r->l;
		else if(k > r->key) r = r->r;
		else return 1;
	}
	return 0;
}
inline void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	Node *z;
	int cnt = 0;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->l = NIL;
	z->r = NIL;
	while (x != NIL) {
		y = x;
		if (x->key > z->key)
			x = x->l;
		else
			x = x->r;
	}
	z->p = y;
	if (y == NIL) {
		root = z;
	}
	else if (y->key > z->key) {
		y->l = z;
	}
	else if (y->key < z->key) {
		y->r = z;
	}
}
int main(){
	int m;
	cin >> m;
	string com;
	int n;
	for (int i = 0; i < m; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &n);
			insert(n);
		}
		else if(com == "print"){
			in(root);
			cout << endl;
			pre(root);
			cout << endl;
		}
		else {
			scanf("%d", &n);
			if (find(n)) cout << "yes" << endl;
			else cout << "no" << endl;
		}

	}
	return 0;
}
```