import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array.Unboxed

main :: IO ()
main = do
  n <- getl toInt
  solve <$> replicateM n (getl words) >>= print

solve :: [[String]] -> Int
solve xs
  | check 1 2 1 2 = 1
  | otherwise = 0
  where
    ia = listArray ((1,1),(100,100)) (repeat 0) :: UArray (Int,Int) Int
    db = foldl f ia xs
    f a [u,c,d]
      | c == "lock" = a // [((read u, read d), 1)]
      | otherwise = a // [((read u, read d), 3)]
    check i j k l
      | i == 100 = False
      | j == 101 = check (i+1) (i+2) 1 2
      | k == 100 = check i (j+1) 1 2
      | l == 101 = check i j (k+1) (k+2)
      | otherwise = if abs (db ! (i,k) - db ! (i,l)) == 2 && db ! (i,k) == db ! (j,l) && db ! (i,l) == db ! (j,k) then True else check i j k (l+1)

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine