import Data.List

f::Int->Int->Int->[((Int,Int),Int)]
f (-1) _ _ =[]
f p h w=let y=p `div` w
            x=p `mod` w
            ts=sort $ [(y,x),(h-1-y,x),(y,w-1-x),(h-1-y,w-1-x)]
            c=length $ nub $ ts
        in (head ts,c):f (p-1) h w
g ::[Int]->[Int]
g []=[]
g (x:xs)
   |x>4 =4:(g ((x-4):xs))
   |x==3=1:2:(g xs)
   |otherwise=x:g xs

f2::[Int]->[Int]->[Int]
f2 [] ys=ys
f2 _ []=[]
f2 (x:xs) (y:ys)
   |x<y=f2 xs (y:ys)
   |x>y=y:(f2 (x:xs) ys)
   |x==y=f2 xs ys

f3::[Int]->[Int]->Bool
f3 [] _=True
f3 _ []=True
f3 xs ys
   |((nub xs)==[4]) && ((nub ys)==[2])&&((sum(xs))==(sum(ys)))=True
   |otherwise=False

main = do
       x<-getLine
       as<-getContents
       let xs=sort $ g $ map length $ group $ sort $ concat (lines as)
           (h:w:[])=map read (words x)::[Int]
           ys=sort $ map snd $ nub $ f (h*w-1) h w
           ys2=f2 xs ys
           xs2=f2 ys xs
       putStrLn $ if f3 xs2 ys2 then "Yes" else "No"