import Control.Applicative
import Control.Monad
import Control.Monad.State

main = do
        n <- readLn
        execStateT (replicateM n runQuery) (Node Null Null Null Null False)

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

nullNode = Node Null Null Null Null False

queryInsert :: String -> StateT Dictionary IO ()
queryInsert str = get >>= \d -> put (insert str d)

insert :: String -> Dictionary -> Dictionary
insert [x] Null = case x of
                      'A' -> Node (nullNode {end = True}) Null Null Null False
                      'C' -> Node Null (nullNode {end = True}) Null Null False
                      'G' -> Node Null Null (nullNode {end = True}) Null False
                      'T' -> Node Null Null Null (nullNode {end = True}) False
insert [x] dict = case x of
                      'A' -> dict { a = ((a dict) {end = True}) }
                      'C' -> dict { c = ((c dict) {end = True}) }
                      'G' -> dict { g = ((g dict) {end = True}) }
                      'T' -> dict { t = ((t dict) {end = True}) }
insert xs Null = insert xs nullNode
insert (x:xs) dict = case x of
                         'A' -> dict { a = insert xs (a dict) }
                         'C' -> dict { c = insert xs (c dict) }
                         'G' -> dict { g = insert xs (g dict) }
                         'T' -> dict { t = insert xs (t dict) }

queryFind :: String -> StateT Dictionary IO ()
queryFind str = do
        dict <- get
        if find str dict then liftIO $ putStrLn "yes"
                         else liftIO $ putStrLn "no"

find :: String -> Dictionary -> Bool
find _ Null = False
find [] dict = end dict
find (x:xs) dict
    | x == 'A' = find xs (a dict)
    | x == 'C' = find xs (c dict)
    | x == 'G' = find xs (g dict)
    | x == 'T' = find xs (t dict)

runQuery = do
        com <- liftIO getCommand
        com

getCommand :: IO (StateT Dictionary IO ())
getCommand = do
        [com,str] <- words<$>getLine
        case com of
            "insert" -> return $ queryInsert str
            "find"   -> return $ queryFind str