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

main :: IO ()
main = do
  [h, w] <- 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
  putStrLn $ case (even h, even w) of
    (True,True) -> if all (==0) [nss,nts] then "YES" else "NO"
    (True,False) -> if nss==0 && nts==1 then "YES" else "NO"
    (False,True) -> if nss==1 && nts==0 then "YES" else "NO"
    (False,False) -> if all (==1) [nss,nts] then "YES" else "NO"
