module Main where type Input = [[String]] type Output = [Bool] parse :: String -> Input parse = map words . map snd . filter fst . zip (cycle [False, True]) . tail . lines solve :: Input -> Output solve input = let f (x1:x2:x3:x4:x5: xs) = and [cond1, cond2, cond3] && f xs where cond1 = x1 /= x2 cond2 = x1 == x3 cond3 = x2 == x4 && x2 == x5 f _ = True in map f input render :: Output -> String render output = let f True = "Yes" f False = "No" in unlines . map f $ output main :: IO () main = interact ( render . solve . parse )