module Trie = struct
  type 'a t = {mutable is_term : bool;
               next : 'a t option array}

  let to_int c = match c with 'A' -> 0 | 'C' -> 1 | 'G' -> 2 | _ -> 3

  let create () =
    {is_term = false; next = Array.make 4 None}

  let insert t str =
    let len = String.length str in
    let rec loop node = function
        i when i = len -> node.is_term <- true
      | i ->
        let ind = to_int str.[i] in
        match node.next.(ind) with
          None ->
          let new_node = create () in
          node.next.(ind) <- Some new_node;
          loop new_node (i+1)
        | Some e -> loop e (i+1)
    in loop t 0

  let find t str =
    let len = String.length str in
    let rec loop node = function
      i when i = len -> node.is_term
      | i ->
        let ind = to_int str.[i] in
        match node.next.(ind) with
          None -> false
        | Some e -> loop e (i+1)
    in loop t 0
  
end

let () =
  let n = read_int () in
  let t = Trie.create () in
  let rec loop = function
      0 -> ()
    | i ->
      begin match Scanf.scanf "%s %s\n" (fun a b -> a,b) with
          "insert", word -> Trie.insert t word
        | _, word ->
          print_endline (if Trie.find t word then "yes" else "no")
      end;
      loop (i-1)
  in loop n