class State(private val state: Array<List<Int>>) {
    private val rows = state.indices.toList().toIntArray()
    private val columns = state.first().indices.toList().toIntArray()
    private val sumByRow = state.indices.map{y -> state[y].sum()}
    private val sumByColumn = state.first().indices.map{x -> state.sumBy{it[x]}}
    operator fun get(x: Int, y: Int): Int = state[rows[y]][columns[x]]
    val width: Int = state.first().size
    val height: Int = state.size
    fun countByRow(row: Int): Int = sumByRow[rows[row]]
    fun countByColumn(column: Int): Int = sumByColumn[columns[column]]
    val allBlack: Int = sumByRow.sum()
    val rowIndices: IntRange = rows.indices
    val columnIndices: IntRange = columns.indices
    fun swapColumn(a: Int, b: Int): Unit {
        val temp = columns[a]
        columns[a] = columns[b]
        columns[b] = temp
    }
    fun swapRow(a: Int, b: Int): Unit {
        val temp = rows[a]
        rows[a] = rows[b]
        rows[b] = temp
    }
}


fun main(args: Array<out String>?): Unit {
    val (w, h) = readLine()!!.trim().split(' ').map(String::toInt)
    val state = State(Array(h){readLine()!!.trim().split(' ').map(String::toInt)})
    if (w * h % 2 == 1) {
        if (state.allBlack == w * h / 2) {
            state.rowIndices.find{y ->
                state.countByRow(y) == h / 2
            }?.let{y -> state.swapRow(0, y)} ?: return println("no")
            for (i in state.columnIndices) {
                (i until w).find{x ->
                    state[x, 0] == i % 2
                }?.let{x -> state.swapColumn(i, x) } ?: return println("no")
            }
        }else if (w * h - state.allBlack == w * h / 2){
            state.rowIndices.find{y ->
                state.countByRow(y) + h / 2 == h
            }?.let{y -> state.swapRow(0, y)} ?: return println("no")
            for (i in state.columnIndices) {
                (i until w).find{x ->
                    state[x, 0] == (i + 1) % 2
                }?.let{x -> state.swapColumn(i, x)} ?: return println("no")
            }
        }else return println("no")
    }else {
        if (h % 2 == 1) {
            state.columnIndices.find{x ->
                state.countByColumn(x) == h / 2 // white > black
            }?.let{x -> state.swapColumn(0, x)} ?: return println("no")
            state.rowIndices.find{y ->
                state[0, y] == 0
            }?.let{y -> state.swapRow(0, y)} ?: return println("no")
            for (i in state.columnIndices) {
                (i until w).find{x ->
                    state[x, 0] == i % 2
                }?.let{x -> state.swapColumn(i, x)} ?: return println("no")
            }
        }else {
            val left = if (state.countByRow(0) * 2 > w) 1 else 0
            for (i in state.columnIndices) {
                (i until w).find{x ->
                    state[x, 0] == (i + left) % 2
                }?.let{x -> state.swapColumn(i, x)} ?: return println("no")
            }
        }
    }
    for (i in 1 until h){
        (i until h).find{y ->
            state[0, y] == (state[0, 0] + i) % 2
        }?.let{y -> state.swapRow(i, y)} ?: return println("no")
    }
    println (
            if (state.rowIndices.all{y -> state.columnIndices.all{x -> state[x, y] == (state[0, 0] + x + y) % 2}}) "yes" else "no"
    )
}
