#define _USE_MATH_DEFINES

#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>
#include <cmath>
#include <iomanip>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		std::string input;;
		for (int i = 0; i < num && std::getline(sstr, input, delim); ++i)
		{
			retval.push_back(std::stoi(input));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename Itr>
	void PrintLine(Itr begin, Itr end)
	{
		bool first = true;

		for (int i = 0; begin != end; ++begin, ++i)
		{
			if (!first)
			{
				std::cout << ' ';
			}

			std::cout << (*begin);

			first = false;
		}
		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

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

		Node(int k)
			: key(k)
			, parent(nullptr)
			, left(nullptr)
			, right(nullptr)
		{}
	};

	Node* root = nullptr;

	void Insert(int key)
	{
		auto n = new Node(key);
		
		if (root == nullptr)
		{
			root = n;
			return;
		}

		Node* current = root;
		Node* parent = current;
		bool right = true;
		while (current != nullptr)
		{
			parent = current;
			if (current->key < key)
			{
				current = current->right;
				right = true;
			}
			else
			{
				current = current->left;
				right = false;
			}
		}

		n->parent = parent;
		if (right)
		{
			parent->right = n;
		}
		else
		{
			parent->left = n;
		}
	}

	void Inorder(Node* n)
	{
		if (n == nullptr)
			return;

		Inorder(n->left);
		std::cout << ' ' << n->key;
		Inorder(n->right);
	}

	void Preorder(Node* n)
	{
		if (n == nullptr)
			return;

		std::cout << ' ' << n->key;
		Preorder(n->left);
		Preorder(n->right);
	}

	bool Find(Node* node, int key)
	{
		if (node == nullptr)
			return false;

		if (node->key == key)
			return true;

		if (node->key < key)
			return Find(node->right, key);
		else
			return Find(node->left, key);
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int num;
	stream >> num;

	char command[7];
	int key;

	for (int i = 0; i < num; ++i)
	{
		stream >> command;

		if (command[0] == 'i')
		{
			stream >> key;
			Insert(key);
		}
		else if(command[0] == 'p')
		{
			Inorder(root);
			std::cout << '\n';
			Preorder(root);
			std::cout << std::endl;
		}
		else
		{
			stream >> key;
			if (Find(root, key))
			{
				std::cout << "yes" << std::endl;
			}
			else
			{
				std::cout << "no" << std::endl;
			}
		}
	}
}



Measured memory_bytes: 21932