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 OCaml (judge verdict: Accepted)

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