{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE OverloadedStrings #-}

import           Control.Applicative
import           Control.Monad
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

import           Prelude               hiding (getChar)

import           Data.Array.IO
import           Data.Array.MArray

-- 螺旋本の移植

-- n以上の素数
_M :: Int
_M = 1046527

getChar :: Char -> Int
getChar 'A' = 1
getChar 'C' = 2
getChar 'G' = 3
getChar 'T' = 4
getChar _   = 0

-- 逆順にしたものを5進数とみなして10進数に変換
-- 例：ACG -> 321 -> 86
getKey :: ByteString -> Int
getKey bs = go 0 1 bs
  where
    go !s !p cs =
        case B.uncons cs of
            Nothing      -> s
            Just (x, xs) -> go (s + p * getChar x) (p * 5) xs

h1 :: Int -> Int
h1 key = key `mod` _M

h2 :: Int -> Int
h2 key = 1 + key `mod` (_M - 1)

find :: ByteString -> IOArray Int ByteString -> IO Bool
find bs ary = go 0
  where
    key = getKey bs
    v1 = h1 key
    v2 = h2 key

    go :: Int -> IO Bool
    go !i = do
        let h = (v1 + i * v2) `mod` _M
        v <- readArray ary h
        case () of
            _ | v == bs   -> return True
              | B.null v  -> return False
              | otherwise -> go (i + 1)

insert :: ByteString -> IOArray Int ByteString -> IO (IOArray Int ByteString)
insert bs ary = go 0
  where
    key = getKey bs
    v1 = h1 key
    v2 = h2 key

    go :: Int -> IO (IOArray Int ByteString)
    go !i = do
        let h = (v1 + i * v2) `mod` _M
        v <- readArray ary h
        case () of
            _ | v == bs   -> return ary
              | B.null v  -> writeArray ary h bs >> return ary
              | otherwise -> go (i + 1)

solve :: IOArray Int ByteString -> [(ByteString, ByteString)] -> IO ()
solve ary commands = go ary commands
  where
    go _ [] = return ()
    go !a ((c, b):cs)
        | B.head c == 'i' = insert b a >> go a cs
        | B.head c == 'f' = do
            exists <- find b a
            if exists
                then putStrLn "yes" >> go a cs
                else putStrLn "no" >> go a cs

main :: IO ()
main = do
    B.getLine
    xs <- fmap ((\[a,b] -> (a,b)) . B.words) . B.lines <$> B.getContents
    ary <- newArray (0, _M) "" :: IO (IOArray Int ByteString)
    solve ary xs

