#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

#define INF 1 << 28

string to_s(int n) {
    ostringstream oss;
    oss << n;
    return oss.str();
}

int to_i(string s) {
    int n;
    istringstream is;
    is.str(s);
    is >> n;
    return n;
}

int main() {
    int h, w;
    bool nikaime = false;
    while (cin >> h >> w) {
        int field[h+1][w+1];
        string s;
        vector<pair<int, int> > unknown; 
        for (int i = 0; i < h+1; i++) {
            for (int j = 0; j < w+1; j++) {
                cin >> s;
                if (s == "?") {
                    field[i][j] = INF;
                    unknown.push_back(pair<int,int>(i, j));
                } else {
                    field[i][j] = to_i(s);
                }
            }
        }

        for (int k = 0; k < 100; k++) {
        int unknown_x;
        for (int i = 0; i < h; i++) {
            int unknown_count = 0;
            for (int j = 0; j < w; j++) {
                if (field[i][j] == INF) {
                    unknown_count++;
                    unknown_x = j;
                }
            }
            if (unknown_count == 1) {
                int sum = 0;
                for (int j = 0; j < w; j++) {
                    if (j != unknown_x) {
                        sum += field[i][j];
                    }
                }
                field[i][unknown_x] = field[i][w] - sum;
            }
        }
                    
        int unknown_y;
        for (int i = 0; i < w; i++) {
            int unknown_count = 0;
            for (int j = 0; j < h; j++) {
                if (field[j][i] == INF) {
                    unknown_count++;
                    unknown_y = j;
                }
            }
            if (unknown_count == 1) {
                int sum = 0;
                for (int j = 0; j < h; j++) {
                    if (j != unknown_y) {
                        sum += field[j][i];
                    }
                }
                field[unknown_y][i] = field[h][i] - sum;
            }
        }
        }

//        int unknown_x;
//        for (int i = 0; i < h; i++) {
//            int unknown_count = 0;
//            for (int j = 0; j < w; j++) {
//                if (field[i][j] == INF) {
//                    unknown_count++;
//                    unknown_x = j;
//                }
//            }
//            if (unknown_count == 1) {
//                int sum = 0;
//                for (int j = 0; j < w; j++) {
//                    if (j != unknown_x) {
//                        sum += field[i][j];
//                    }
//                }
//                field[i][unknown_x] = field[i][w] - sum;
//            }
//        }

        string ans;
        for (int i = 0; i < unknown.size(); i++) {
            if (field[unknown[i].first][unknown[i].second] == INF) {
                ans = "NO\n";
                break;
            } else {
                ans += to_s(field[unknown[i].first][unknown[i].second]);
                ans += "\n";
            }
        }

        if (nikaime) {
            cout << endl;
        }

        cout << ans;

        nikaime = true;
 
//        for (int i = 0; i < h+1; i++) {
//            for (int j = 0; j < w+1; j++) {
//                if (field[i][j] == INF) {
//                    cout << "x ";
//                } else {
//                    cout << field[i][j] << ' ';
//                }
//            }
//            cout << endl;
//        }
    }
    return 0;
}