sub x{exit!print"No"} ($h,$w)=glob<>; @s=<>; ($s[0]^$s[$_])=~/^(.)\1*.$/||x for 1..$h-1; $t[$`][$']=/ / for@s[$h+1..$#s]; $t[1][$_]|$s[$_-1]ne$s[$_]||x for 1..$h-1; $t[2][$_]|vec($s[0],$_-1,8)-vec($s[0],$_,8)||x for 1..$w-1; print"Yes";