main :: IO()
main = do
    n <- readLn
    {-replicateM n getLine←これ使うline送ってもらったしdiscodeにも書いてあるからそれ参考に頑張れ！-}
    let list = scan n
    case loop n list  of
        False -> "No"
        True  
            | case () of
                _
                    | (siritori list n ) > 0  = "No"
                    | otherwise = "Yes"
    --if loop == False then "No" else "Yes"

scan :: String -> IO [String]
scan 0 = return []
scan n = do
    w <- getLine
    l <- scan $ n-1
    return w:l

loop :: [a] -> Bool
loop (x:xs) = elemm x xs

elemm :: (Eq a) => a -> [a] -> Bool
elemm a [] = False
elemm a (x:xs)
    | ( x == a ) = True
    | otherwise = elemm a xs

siritori :: String -> a -> Bool
siritori (n == 0) = 0
siritori list n
    | last (list !! n-1) == head (list !! n) = 0 + (siritori list n-1)
    | otherwise = 1 + (siritori list n-1)