class BinaryTree:
    class Node:
        def __init__(self, n):
            self.num = n
            self.parent = -1
            self.right = None
            self.left = None

    
    def __init__(self):
        self.root = None


    def insert(self, n):
        if not self.root:
            node = self.Node(n)
            self.root = node
        else:
            current, parent = self.root, None
            while current:
                parent = current
                if n < current.num:
                    current = current.left
                else:
                    current = current.right
            node = self.Node(n)
            node.parent = parent
            if n < parent.num:
                parent.left = node
            else:
                parent.right = node
                
            
    def find(self, n):
        if not self.root:
            return None
        current = self.root
        while current:
            if current.num == n:
                print('yes')
                return 
            elif n < current.num:
                current = current.left
            else:
                current = current.right
        print('no')

#    def load(self, tree_info):
#        for i in range(self.node_num):
#            self.nodes[i].num = tree_info[i][0]
#            self.nodes[i].left = tree_info[i][1]
#            self.nodes[i].right = tree_info[i][2]
#            if self.nodes[i].left != -1:
#                self.nodes[self.nodes[i].left].parent = self.nodes[i].num
#            if self.nodes[i].right != -1:
#                self.nodes[self.nodes[i].right].parent = self.nodes[i].num


    
    def print_preorder(self, node):
        if not node.left and not node.right:
            return [node.num]
        elif not node.left:
            return [node.num] + self.print_preorder(node.right)
        elif not node.right:
            return [node.num] + self.print_preorder(node.left)
        else:
            return [node.num] + self.print_preorder(node.left) + self.print_preorder(node.right)


    def print_inorder(self, node):
        if not node.left and not node.right:
            return [node.num]
        elif not node.left:
            return [node.num] + self.print_inorder(node.right)
        elif not node.right:
            return self.print_inorder(node.left) + [node.num]
        else:
            return self.print_inorder(node.left) + [node.num] + self.print_inorder(node.right)


    def print_postorder(self, node):
        if not node.left and not node.right:
            return [node.num]
        elif not node.left:
            return self.print_inorder(node.right) + [node.num]
        elif not node.right:
            return self.print_inorder(node.left) + [node.num]
        else:
            return self.print_inorder(node.left) + self.print_inorder(node.right) + [node.num]



if __name__ == '__main__':
    n = int(input())
    qs = [ input().rstrip().split() for _ in range(n) ]
    bt = BinaryTree()
    for q in qs:
        if q[0] == 'insert':
            bt.insert(int(q[1]))
        elif q[0] == 'find':
            bt.find(int(q[1]))
        elif q[0] == 'print':
            print(' ' + ' '.join(map(str,bt.print_inorder(bt.root))))
            print(' ' + ' '.join(map(str,bt.print_preorder(bt.root))))


Measured memory_bytes: 257588