#include <iostream>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;

int main() {
    const int INF = 10000000;
    int table[102][12], questionsInRow[100], questionsInColumn[10];
    bool insertSpace = false;
    while (true) {
        int p, s;
        cin >> p >> s;
        if (p == 0) {
            break;
        }
        int questionNum = 0;
        vector<pair<int, int> > res;
        memset(table, 0, sizeof(table));
        memset(questionsInRow, 0, sizeof(questionsInRow));
        memset(questionsInColumn, 0, sizeof(questionsInColumn));
        for (int y = 0; y <= p; y++) {
            for (int x = 0; x <= s; x++) {
                string input;
                cin >> input;
                if (input == "?") {
                    table[y][x] = INF;
                    questionsInRow[y]++;
                    questionsInColumn[x]++;
                    questionNum++;
                    res.push_back(make_pair(y, x));
                } else {
                    stringstream sstream;
                    sstream << input;
                    sstream >> table[y][x];
                    if (x < s) {
                        table[y][s + 1] += table[y][x];
                    }
                    if (y < p) {
                        table[p + 1][x] += table[y][x];
                    }
                }
            }
        }
        queue<pair<int, int> > solves;
        while (questionNum > 0) {
            for (int x = 0; x < s; x++) {
                  if (questionsInColumn[x] == 1) {
                    for (int y = 0; y < p; y++) {
                        if (table[y][x] == INF) {
                            solves.push(make_pair(y, x));
                        }
                    }
                }
            }
              for (int y = 0; y < p; y++) {
                  if (questionsInRow[y] == 1) {
                    for (int x = 0; x < s; x++) {
                        if (table[y][x] == INF) {
                            solves.push(make_pair(y, x));
                        }
                    }
                }
            }
              if (solves.empty()) {
                break;
            }
            while (solves.empty() == false) {
                int cy = solves.front().first, cx = solves.front().second;
                solves.pop();
                if (table[cy][cx] != INF) {
                    continue;
                }
                if (questionsInColumn[cx] == 1) {
                    table[cy][cx] = table[p][cx] - table[p + 1][cx];
                } else if (questionsInRow[cy] == 1) {
                    table[cy][cx] = table[cy][s] - table[cy][s + 1];
                }
                table[p + 1][cx] += table[cy][cx];
                table[cy][s + 1] += table[cy][cx];
                questionsInColumn[cx]--;
                questionsInRow[cy]--;
                questionNum--;
            }
        }
        if (insertSpace) {
            cout << endl;
        } else {
            insertSpace = true;
        }
        if (questionNum > 0) {
            cout << "NO" << endl;
        } else {
            for (vector<pair<int, int> >::iterator it = res.begin(); it != res.end(); it++) {
                cout << table[it->first][it->second] << endl;
            }
        }
    }
}

Measured memory_bytes: 956