### main

first = true

loop do
  pn, sn = gets.split.map(&:to_i)
  break if pn == 0

  tbl = (pn + 1).times.map{[]}
  vars = []

  hnvs = [0] * (pn + 1)
  vnvs = [0] * (sn + 1)

  for y in (0..pn)
    vals = gets.strip.split
    for x in (0..sn)
      if vals[x] == '?'
        tbl[y][x] = nil
        vars << [x, y]
        hnvs[y] += 1
        vnvs[x] += 1
      else
        tbl[y][x] = vals[x].to_i
      end
    end
  end
  #p tbl
  #p vars
  #p hnvs
  #p vnvs

  gets

  nv = vars.length
  changed = true

  while nv > 0 && changed
    changed = false

    for var in vars
      x, y = var

      if hnvs[y] == 1 && tbl[y][x].nil?
        sum = 0
        for x0 in (0...sn)
          if x0 != x
            sum += tbl[y][x0]
          end
        end

        if x == sn
          tbl[y][x] = sum
        else
          tbl[y][x] = tbl[y][sn] - sum
        end

        nv -= 1
        hnvs[y] -= 1
        vnvs[x] -= 1
        changed = true
      end

      if vnvs[x] == 1 && tbl[y][x].nil?
        sum = 0
        for y0 in (0...pn)
          if y0 != y
            sum += tbl[y0][x]
          end
        end

        if y == pn
          tbl[y][x] = sum
        else
          tbl[y][x] = tbl[pn][x] - sum
        end

        nv -= 1
        hnvs[y] -= 1
        vnvs[x] -= 1
        changed = true
      end
    end
  end

  puts "" if ! first
  first = false

  if nv > 0
    puts 'NO'
  else
    for var in vars
      x, y = var
      puts tbl[y][x]
    end
  end
end