using System;
using System.Collections.Generic;
using System.Text;

class Program
{

    public void Proc()
    {
        int cmdCount = int.Parse(Console.ReadLine());
        TreeNd root = null;

        for (int i = 0; i < cmdCount; i++)
        {
            string[] inpt = Console.ReadLine().Split(' ');
            if (inpt[0].Equals("print"))
            {
                this.GetInorderText(root);
                Console.WriteLine(string.Empty);
                this.GetPreorderText(root);
                Console.WriteLine(string.Empty);
            }
            else if (inpt[0].Equals("find"))
            {
                long target = long.Parse(inpt[1]);
                TreeNd parent = root;
                bool isFinded = false;
                for (int j = 0; j < cmdCount; j++)
                {
                    if (parent == null)
                    {
                        break;
                    }
                    if (parent.NodeId == target)
                    {
                        isFinded = true;
                        break;
                    }
                    else if (parent.NodeId < target)
                    {
                        parent = parent.RightChild;
                    }
                    else
                    {
                        parent = parent.LeftChild;
                    }
                }
                Console.WriteLine(isFinded ? "yes" : "no");
            }
            else
            {
                long num = long.Parse(inpt[1]);
                if (root == null)
                {
                    root = new TreeNd(num);
                }
                else
                {
                    TreeNd target = root;
                    for (int j = 0; j < cmdCount; j++)
                    {
                        if (target.NodeId > num)
                        {
                            if (target.LeftChild == null)
                            {
                                target.LeftChild = new TreeNd(num);
                                target.LeftChild.Parent = target;
                                break;
                            }
                            else
                            {
                                target = target.LeftChild;
                            }
                        }
                        else
                        {
                            if (target.RightChild == null)
                            {
                                target.RightChild = new TreeNd(num);
                                target.RightChild.Parent = target;
                                break;
                            }
                            else
                            {
                                target = target.RightChild;
                            }
                        }
                    }
                }
            }

        }
        // ????????????

    }

    private void GetPreorderText(TreeNd root)
    {
        Console.Write(" " + root.NodeId);
        if (root.LeftChild != null)
        {
            this.GetPreorderText(root.LeftChild);
        }
        if (root.RightChild != null)
        {
            this.GetPreorderText(root.RightChild);
        }
    }

    private void GetInorderText(TreeNd root)
    {
        if (root.LeftChild != null)
        {
            this.GetInorderText(root.LeftChild);
        }
        Console.Write(" " + root.NodeId);
        if (root.RightChild != null)
        {
            this.GetInorderText(root.RightChild);
        }
    }

    public class TreeNd
    {
        public TreeNd Parent;
        public long NodeId;
        public TreeNd LeftChild;
        public TreeNd RightChild;


        public TreeNd(long nodeid)
        {
            this.NodeId = nodeid;
        }


    }


    static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 39200