import Data.List m@main=getLine>>=putStrLn.min"YES".foldl1(!).words>>m a!b|isInfixOf a b=b|0<1="NO"