import Control.Monad                                                                                                       
import Data.List                                                                                                           
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- read <$> getLine                                                                                                    
  ws <- replicateM n getLine                                                                                               
                                                                                                                           
  if existSame ws                                                                                                          
    then putStrLn "No"                                                                                                     
    else if (all id . map shiritori) $ zip ws (tail ws)                                                                    
         then putStrLn "Yes"                                                                                               
         else putStrLn "No"                                                                                                
                                                                                                                           
                                                                                                                           
existSame :: Eq a => [a] -> Bool                                                                                           
existSame xs = (length xs) /= (length $ nub xs)                                                                            
                                                                                                                           
                                                                                                                           
shiritori :: (String, String) -> Bool                                                                                      
shiritori (a:[], b:_)                                                                                                      
  | a == b = True                                                                                                          
  | otherwise = False                                                                                                      
shiritori (as, b:_)                                                                                                        
  | last as == b = True                                                                                                    
  | otherwise    = False                                                                                                   
shiritori _ = False

Measured memory_bytes: 636