#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *root, int key)
{
	while (root != NIL && key != root->key)
	{
		if (key < root->key) root = root->left;
		else root = root->right;
	}
	return root;
}

void insert(int key)
{
	Node *x = root;
	Node *y = NIL;
	Node *z;

        z = (Node *)malloc(sizeof(Node));
	z->key = key;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}

	z->parent = y;
	if (y == NIL) root = z;
	else
	{
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node *root)
{
	if (root == NIL) return;
	inorder(root->left);
	cout << " " << root->key;
	inorder(root->right);
}

void preorder(Node *root)
{
	if (root == NIL) return;
	cout << " " << root->key;
	preorder(root->left);
	preorder(root->right);
}

int main()
{
	int n, key;
	string str;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> str;
		if (str == "find")
		{
			cin >> key;
			Node *t = find(root, key);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (str == "insert")
		{
			cin >> key;
			insert(key);
		}
		else if (str == "print")
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}

	return 0;
}