using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{    

    class Node
    {
        public int? key = null;
        public Node left;
        public Node right;
    }

    class Program
    {       
        static Node root;
        static Node u;

        static void Insert(int k)
        {         
            u = root;

            while(true)
            {
                if(k < u.key)
                {
                    if(u.left == null)
                    {
                        Node newnode = new Node();
                        u.left = newnode;
                        newnode.key = k;
                        break;
                    }
                    else
                    {
                        u = u.left;
                    }                 
                }
                else if(k > u.key)
                {
                    if(u.right == null)
                    {
                        Node newnode = new Node();
                        u.right = newnode;
                        newnode.key = k;
                        break;
                    }
                    else
                    {
                        u = u.right;
                    }                  
                }
            }          
            return;
        }


        static bool Find(int k)
        {
            u = root;

            while (true)
            {

                if (u.key == k)
                {
                    return true;
                }

                if (k < u.key)
                {
                    if (u.left == null)
                    {                       
                        return false;
                    }
                    else
                    {
                        u = u.left;
                    }
                }
                else if (k > u.key)
                {
                    if (u.right == null)
                    {
                        return false;
                    }
                    else
                    {
                        u = u.right;
                    }
                }
                
            }

        }

        static void Pre(Node u)
        {
            if(u == null)
            {
                return;
            }
            Console.Write(" " + u.key);
            Pre(u.left);
            Pre(u.right);
        }

        static void Ino(Node u)
        {
            if(u == null)
            {
                return;
            }
            Ino(u.left);
            Console.Write(" " + u.key);
            Ino(u.right);
        }
        
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] input;
            string order;
            int key;

            u = new Node();

            for (int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');
                order = input[0];

                if(order == "insert")
                {
                    key = int.Parse(input[1]);
                    if(i == 0)
                    {
                        root = new Node();
                        root.key = key;
                        root.left = null;
                        root.right = null;
                    }
                    else
                    {
                        Insert(key);
                    }                 
                }
                else if(order == "print")
                {
                    Ino(root);
                    Console.WriteLine();
                    Pre(root);
                    Console.WriteLine();
                }
                else if(order == "find")
                {
                    key = int.Parse(input[1]);
                    if (Find(key))
                    {
                        Console.WriteLine("yes");
                    }
                    else
                    {
                        Console.WriteLine("no");
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 34104