require 'prime'

class Dictionary
  CHAR_MAP = {
    'A' => 1,
    'C' => 2,
    'G' => 3,
    'T' => 4
  }

  def initialize(size)
    @size = size
    @m = Prime::EratosthenesGenerator.new.find {|p| p > @size }
    @values = Array.new(@m)
  end

  def insert(value)
    key = get_key(value)
    i = 0

    loop do
      h = (h1(key) + i * h2(key)) % @m

      if value == @values[h]
        return true
      elsif !@values[h]
        @values[h] = value
        return false
      end

      i += 1
    end
  end

  def find(value)
    key = get_key(value)
    i = 0

    loop do
      h = (h1(key) + i * h2(key)) % @m

      if value == @values[h]
        return true
      elsif !@values[h]
        return false
      end
    end
  end

  private

  def h1(key)
    key % @m
  end

  def h2(key)
    1 + (key % (@m - 1))
  end

  def get_key(value)
    factor = 1
    value.each_char.inject(0) do |memo, char|
      memo += factor * char_code(char)
      factor *= 5
      memo
    end
  end

  def char_code(value)
    CHAR_MAP[value] || 0
  end
end

n = gets.to_i

dict = Dictionary.new(n)

while line = gets
  command, value = line.split

  case command
  when 'insert'
    dict.insert(value)
  when 'find'
    puts dict.find(value) ? 'yes' : 'no'
  else
    abort "unknown command: #{command}"
  end
end