def contain_nil?(matrix)
    matrix.each do |array|
        array.each {|e| return true if e == nil }
    end
    return false
end

def contain_one_nil?(array)
    count = 0
    index = nil
    array.each_with_index do |e, i|
        if e == nil
            count += 1 if e == nil
            index = i
        end
    end
    index if count == 1
end

def solveArray(array)
    sum = array.last * 2
    array.each do |e|
        sum -= e if e != nil
    end
    sum
end

def solve(pp, ss, matrix)
    while contain_nil?(matrix) do
        flag = false
        # row
        (0..(pp-1)).each do |i|
            array = matrix[i]
            index = contain_one_nil?(array)
            if index
                array[index] = solveArray(array)
                flag = true
                break
            end
        end
        
        # column
        (0..(ss-1)).each do |i|
            array = []
            matrix.each {|e| array << e[i]}
            index = contain_one_nil?(array)
            if index
                matrix[index][i] = solveArray(array)
                flag = true
                break
            end
        end
        
        # not solve
        return unless flag
    end
end

first_flg = true
while true do
    pp, ss = gets.split(' ').map(&:to_i)
    break if pp == 0 && ss == nil
    
    if first_flg
        first_flg = false
    else
        puts
    end
    
    base_matrix = []
    matrix = []
    (pp+1).times do
        array = gets.split(' ').map do |e|
            if e == '?'
                nil
            else
                e.to_i
            end
        end
        matrix << array
        base_matrix << array.dup
    end
    solve(pp, ss, matrix)
    if contain_nil?(matrix)
        puts 'NO'
    else
        base_matrix.each_with_index do |array, i|
            array.each_with_index do |e, j|
                puts matrix[i][j] if e == nil
            end
        end
    end
    gets
end