import Control.Monad.State
import Control.Applicative

data Tree = Null | Node { end :: Bool
                        , a :: Tree
                        , c :: Tree
                        , g :: Tree
                        , t :: Tree
                        } deriving (Show)

main = do
    n <- readLn
    evalStateT (query n) Null

insertT :: String -> Tree -> Tree
insertT [] Null = Node True Null Null Null Null
insertT [] tr = tr {end = True}
insertT (ch:cs) Null = insertT (ch:cs) (Node False Null Null Null Null)
insertT (ch:cs) tr
  | ch == 'A' =  tr {a = insertT cs (a tr)}
  | ch == 'C' =  tr {c = insertT cs (c tr)}
  | ch == 'G' =  tr {g = insertT cs (g tr)}
  | ch == 'T' =  tr {t = insertT cs (t tr)}

findT :: String -> Tree -> Bool
findT _ Null = False
findT [] tr = end tr
findT (ch:cs) tr = findT cs . getNode ch $ tr

getNode ch tree
  | ch == 'A' = a tree
  | ch == 'C' = c tree
  | ch == 'G' = g tree
  | ch == 'T' = t tree

type Query = StateT Tree IO ()

query :: Int -> Query
query 0 = return ()
query n = do
    doQuery
    query (n-1)

doQuery = do
    [com,str] <- liftIO (words<$>getLine)
    case com of
      "insert" -> insertQ str
      "find"   -> findQ str

insertQ :: String -> Query
insertQ str = modify (insertT str)

findQ :: String -> Query
findQ str = do
    tree <- get
    let res = findT str tree
    if res then liftIO (putStrLn "yes")
           else liftIO (putStrLn "no")

