### main

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 y in (0..pn)
      if hnvs[y] == 1
        tl = tbl[y]
        x = tl.index(nil)

        if x == sn
          tbl[y][x] = tl[0...sn].inject(:+)
        else
          tbl[y][x] = tl[sn] - tl[0...sn].select{|v| ! v.nil?}.inject(:+)
        end

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

    for x in (0..sn)
      if vnvs[x] == 1
        tl = (0..pn).map{|y| tbl[y][x]}
        y = tl.index(nil)

        if y == pn
          tbl[y][x] = tl[0...pn].inject(:+)
        else
          tbl[y][x] = tl[pn] - tl[0...pn].select{|v| ! v.nil?}.inject(:+)
        end

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

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