import Control.Monad (replicateM)
import Data.List (sort, transpose, group)

main :: IO ()
main = do
  [h, _] <- map read.words <$> getLine :: IO [Int]
  ss <- replicateM h getLine :: IO [String]
  let ts = transpose ss
      nss = length $ filter odd $ map length $ group $ sort $ map sort ss
      nts = length $ filter odd $ map length $ group $ sort $ map sort ts
      sss = length $ filter odd $ map length $ group $ sort $ concat ss
  putStrLn $ if all (<2) [nss,nts,sss] then "YES" else "NO"
