using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class hello
{
    public static int h, w;
    public static int[,] map, map2;
    public static bool[,] nodata;
    public static int[] rsum, csum;
    public static List<int>[] rnd, cnd;
    public static void Main()
    {
        var first = true;
        while (true)
        {
            var ps = new List<P>();
            var s = Console.ReadLine().Trim();
            if (s == "") continue;
            else if (s == "0") break;
            string[] line = s.Split(' ');
            h = int.Parse(line[0]);
            w = int.Parse(line[1]);
            map = new int[h, w];
            map2 = new int[h, w];
            var p = 0;
            rnd = new List<int>[h];
            cnd = new List<int>[w];
            for (int i = 0; i < h; i++)
            {
                rnd[i] = new List<int>();
                for (int j = 0; j < w; j++) map2[i, j] = p++;
            }
            for (int i = 0; i < w; i++) cnd[i] = new List<int>();
            nodata = new bool[h, w];
            rsum = new int[h];
            csum = new int[w];
            for (int i = 0; i < h; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < w; j++)
                {
                    if (line[j] == "?")
                    {
                        nodata[i, j] = true;
                        rnd[i].Add(map2[i, j]);
                        cnd[j].Add(map2[i, j]);
                        ps.Add(new P { x = i, y = j });
                    }
                    else map[i, j] = int.Parse(line[j]);
                }
                rsum[i] = int.Parse(line[w]);
            }
            line = Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < w; i++) csum[i] = int.Parse(line[i]);
            getAns();
            if (first) first = false;
            else Console.WriteLine();
            if (!check0()) Console.WriteLine("NO");
            else  putAns(ps);
        }
    }
    static bool check0()
    {
        foreach (var x in nodata)
            if (x) return false;
        return true;
    }
    static void putAns(List<P> ps)
    {
        foreach (var x in ps)
            Console.WriteLine(map[x.x, x.y]);
    }
    static void getAns()
    {
        var find = true;
        while (find)
        {
            find = false;
            if (rcheck()) find = true;
            if (ccheck()) find = true;
        }
    }
    static bool ccheck()
    {
        var tt = 0;
        for (int i = 0; i < w; i++)
        {
            if (cnd[i].Count() == 1)
            {
                tt = cnd[i][0];
                cnd[i].Clear();
                var tsum = 0;
                var nodatah = 0;
                for (int j = 0; j < h; j++)
                {
                    if (!nodata[j, i]) tsum += map[j, i];
                    else nodatah = j;
                }
                var ntt = csum[i] - tsum;
                map[nodatah, i] = ntt;
                nodata[nodatah, i] = false;
                rnd[nodatah].Remove(tt);
                return true;
            }
        }
        return false;
    }
    static bool rcheck()
    {
        var tt = 0;
        for (int i = 0; i < h; i++)
        {
            if (rnd[i].Count() == 1)
            {
                tt = rnd[i][0];
                rnd[i].Clear();
                var tsum = 0;
                var nodataw = 0;
                for (int j = 0; j < w; j++)
                {
                    if (!nodata[i, j]) tsum += map[i, j];
                    else nodataw = j;
                }
                var ntt = rsum[i] - tsum;
                map[i, nodataw] = ntt;
                nodata[i, nodataw] = false;
                cnd[nodataw].Remove(tt);
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 18248