import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
import std.container;
class bt(T)
{
    t!T root;
    bool containsKey(T key)
    {
        return root && root.containsKey(key);
    }
    void insert(T key)
    {
        t!T y = null;
        auto x = root;
        auto z = new t!T(key);
        while (x)
        {
            y = x;
            if (z.key < y.key)
            {
                x = x.left;
            }
            else
            {
                 x = x.right;
            }
        }
        z.parent = y;
        if (!y)
        {
            root = z;
        }
        else
        {
            if (z.key < y.key)
            {
                y.left = z;
            }
            else
            {
                y.right = z;
            }
        }
    }
}
class t(T)
{
    T key;
    this(T k)
    {
        key = k;
    }
    t left, right, parent;
    bool containsKey(T k)
    {
        if (key == k)
            return true;
        if (key > k)
            return left && left.containsKey(k);
        else
            return right && right.containsKey(k);
    }
}
void in_(T)(t!T t)
{
    if (!t)
        return;
    in_(t.left);
    write(" ", t.key);
    in_(t.right);
}
void pre(T)(t!T t)
{
    if (!t)
        return;
    write(" ", t.key);
    pre(t.left);
    pre(t.right);
}
void main()
{
    auto c = readln.strip.to!int;
    bt!int b = new bt!int;
    foreach (_; 0..c)
    {
        auto instr = readln.strip.split(" ");
        if (instr.length == 1)
        {
            in_(b.root);
            writeln();
            pre(b.root);
            writeln();
        }
        else
        {
            auto key = instr[1].to!int;
            if (instr[0] == "find")
            {
                writeln(b.containsKey(key) ? "yes" : "no");
            }
            else
            {
                b.insert(key);
            }
        }
    }
}
