Problem:
Search III

Your task is to write a program of a simple dictionary which implements the following instructions:

insert str: insert a string str in to the dictionary

find str: if the distionary contains str, then print 'yes', otherwise print 'no'

Input

In the first line n, the number of instructions is given. In the following n lines, n instructions are given in the above mentioned format.

Output

Print yes or no for each find instruction in a line.

Constraints

A string consists of 'A', 'C', 'G', or 'T'

1 ≤ length of a string ≤ 12

n ≤ 1000000

Sample Input 1

5
insert A
insert T
insert C
find G
find A

Sample Output 1

no
yes

Sample Input 2

13
insert AAA
insert AAC
insert AGA
insert AGG
insert TTT
find AAA
find CCC
find CCC
insert CCC
find CCC
insert T
find TTT
find T

Sample Output 2

yes
no
no
yes
yes
yes

Notes

Template in C

Solution in Ruby (judge verdict: Accepted)

class Node
  def initilize
    @act = false
  end

  def insert(val)
    if val.empty?
      @act=true
    else
      case val[0]
      when 'A'
        @a = Node.new if @a.nil?
        @a.insert(val[1..-1])
      when 'C'
        @c = Node.new if @c.nil?
        @c.insert(val[1..-1])
      when 'G'
        @g = Node.new if @g.nil?
        @g.insert(val[1..-1])
      when 'T'
        @t = Node.new if @t.nil?
        @t.insert(val[1..-1])
      end
    end
  end
  
  def find(val)
    if val.empty?
      return @act
    else
      case val[0]
      when 'A'
        @a and @a.find(val[1..-1])
      when 'C'
        @c and @c.find(val[1..-1])
      when 'G'
        @g and @g.find(val[1..-1])
      when 'T'
        @t and @t.find(val[1..-1])
      end
    end
  end
  
  def dump
    p "@act: #{@act}, a:#{@a}, c:#{@c}, g:#{@g}, t:#{@t}"
  end
end

num = STDIN.gets
commands = STDIN.read.split("\n")

root = Node.new
commands.each do |command|
  proc,arg = command.split(' ')
  # p "command: #{proc} #{arg}"
  case proc
  when 'insert'
    root.insert(arg)
  when 'find'
    if root.find(arg)
      print "yes\n"
    else
      print "no\n"
    end
  end
end