#include <iostream>
#include <string>

using namespace std;

class Node
{
public:
    int key;
    Node *parent, *left, *right;

    Node(int key)
    {
        this->key = key;
        parent = left = right = NULL;
    }
};

class BinarySearchTree
{
    Node *root;

public:
    BinarySearchTree()
    {
        root = NULL;
    }

    void insert(int key)
    {
        Node *node = new Node(key);

        if (root == NULL)
        {
            root = node;
            return;
        }

        Node *target = root;
        
        while (target != NULL)
        {
            if (target->key > node->key)
            { 
                if(target->left != NULL)
                {
                    target = target->left;
                }
                else
                {
                    target->left = node;
                    node->parent = target;
                    target = NULL;
                }
            }
            else
            {
                if(target->right != NULL)
                {
                    target = target->right;
                }
                else
                {
                    target->right = node;
                    node->parent = target;
                    target = NULL;
                }
            }
        }
    }

    Node *  find(int key)
    {
        if (root == NULL)
        {
            return NULL;
        }

        Node *target = root;

        while(target != NULL)
        {
            if (target->key == key)
            {
                return target;
            }
            else if (target->key > key)
            {
                if (target->left != NULL)
                {
                    target = target->left;
                }
                else
                {
                    return NULL;
                }
            }
            else if (target->key < key)
            {
                if (target->right != NULL)
                {
                    target = target->right;
                }
                else
                {
                    return NULL;
                }
            }
        }
        return NULL;
    }

    void printPreOrder(Node *n)
    {
        if (n == NULL)
        {
            return;
        }

        cout << " " << n->key;

        if (n->left != NULL)
        {
            printPreOrder(n->left);
        }

        if (n->right != NULL)
        {
            printPreOrder(n->right);
        }
    }

    void printInOrder(Node *n)
    {
        if (n == NULL)
        {
            return;
        }

        if (n->left != NULL)
        {
            printInOrder(n->left);
        }

        cout << " " << n->key;

        if (n->right != NULL)
        {
            printInOrder(n->right);
        }
    }

    void print()
    {
        if (root == NULL)
        {
            return;
        }

        printInOrder(root);
        cout << endl;
        printPreOrder(root);
        cout << endl;
    }
};

int main()
{
    BinarySearchTree *tree = new BinarySearchTree;

    int m;
    cin >> m;

    for (int i = 0; i < m; i++)
    {
        string message;
        cin >> message;

        if (message == "insert")
        {
            int key;
            cin >> key;
            tree->insert(key);
        }
        else if (message == "print")
        {
            tree->print();
        }
        else if (message == "find")
        {
            int key;
            cin >> key;
            bool result = (tree->find(key) != NULL) ? true:false;
            
            if (result)
            {
                cout << "yes" << endl;
            }
            else
            {
                cout << "no" << endl;
            }
        }
        else if (message == "delete")
        {
            int key;
            cin >> key;
        }

        //cout << message << endl;
    }

    return 0;
}


Measured memory_bytes: 21932