import Data.List
import Data.Function

main = readLn >>= sequence . ($ getLine) . replicate >>= 
  putStrLn . ($ "No") . ($ "Yes") . if' . test

if' p x y = if p then x else y

test :: [String] -> Bool
test xs = valid && unique where
  valid   = and . zipWith ((==) `on` head) (tail xs) . 
            map reverse $ xs
  unique  = all (== 1) . map length . group . sort $ xs