fun main(args: Array<String>){
    val (H , W) = readLine()!!.split(" ").map(String::toInt)
    val a = Array(H,{arrayOfNulls<String>(W)})
    var ans ="Yes"
    for(i in 0..H-1){
        a[i] = readLine()!!.split("").toTypedArray()
    }
    for(i in 0..H-1){
        for(j in 0..W-3){
            if(a[i][j] != a[i][j+1] && a[i][j+1] != a[i][j+2]){
                ans="No"
            }
        }
    }
    for(j in 0..W-1){
        for(i in 0..H-3){
            if(a[i][j] != a[i+1][j] && a[i+1][j] != a[i+2][j]){
                ans="No"
            }
        }
    }
    println(ans)

}

