#include<bits/stdc++.h>
using namespace std;

typedef vector<double> vec;
typedef vector<vec> mat;

const double EPS = 1e-8;

vec gauss_jordan(const mat &A, const vec &b,int k){
  int n = A.size();
  mat B(n, vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      B[i][j] = A[i][j];
  for(int i=0;i<n;i++) B[i][n] = b[i];

  for(int i=0;i<k;i++){
    int pivot = i;
    for(int j=i+1;j<n;j++) if(fabs(B[j][i]) > fabs(B[pivot][i])) pivot = j;
    swap(B[i],B[pivot]);

    //ティツァツ」テ」ツ?古」ツ?ェテ」ツ??」ツ?凝」ツ??」ツ?づ」ツ?」テ」ツ?ヲテ」ツつづ、ツクツ?ヲツ?湘」ツ?ァテ」ツ?ッテ」ツ?ェテ」ツ??」ツ??
    if(fabs(B[i][i]) < EPS) return vec();
    
    for(int j=i+1;j<=n;j++) B[i][j] /= B[i][i];
    for(int j=0;j<n;j++)
      if(i != j)
	for(int k=i+1;k<=n;k++)
	  B[j][k] -= B[j][i] * B[i][k];
  }
  vec x(n);
  for(int i=0;i<n;i++) x[i] = B[i][n];
  return x;
}


int X[111][111];
int C[111][111];
int P,S;

bool check(const vec &v){  
  for(int i=0;i<=P;i++)
    for(int j=0;j<=S;j++)
      if( C[i][j] != -1 )
        X[i][j] = (int)round(v[C[i][j]]);  
  for(int i=0;i<=P;i++){
    int sum = 0;
    for(int j=0;j<S;j++) sum += X[i][j];
    if( sum != X[i][S] ) return false;
  }
  for(int j=0;j<=S;j++){    
    int sum = 0;
    for(int i=0;i<P;i++) sum += X[i][j];
    if( sum != X[P][j] ) return false;
  }  
  return true;
}

void view(vec& v){
  for( auto a : v )
    cout << a << " ";
  cout << endl;
}

const int INF = (1<<29);
int main(){

  while( cin >> P && P ){
    cin >> S;
    memset( C,-1,sizeof(C) );
    memset( X,0,sizeof(X));
    int cnt = 0;
    for(int i=0;i<=P;i++){
      for(int j=0;j<=S;j++){
        string s; cin >> s;
        if( s == "?" ) C[i][j] = cnt++;
        else X[i][j] = stoi(s);
      }
    }
    
    static int ttt=0;
    if( ttt++ ) cout << endl;

    int n = P+S+1;

    if( cnt >  n ) {
      cout <<"NO" << endl;
      continue;
    }
    
    mat M = mat(n,vec(n));
    vec V = vec(n);
    set<vec> F;
    int k = 0;
    for(int i=0;i<P;i++){
      V[k] = 0;
      for(int j=0;j<S;j++){
        if( C[i][j] != -1 ) M[k][C[i][j]] = 1;
        else V[k] -= X[i][j];
      }
      V[k] += X[i][S];
      k++;
    }

    for(int j=0;j<S;j++){
      V[k] = 0;
      for(int i=0;i<P;i++){
        if( C[i][j] != -1 ) M[k][C[i][j]] = 1;
        else V[k] -= X[i][j];
      }
      V[k] += X[P][j];
      k++;
    }

    for(int i=0;i<P;i++)
      for(int j=0;j<S;j++){
        if( C[i][j] != -1 ) M[k][C[i][j]] = 1;
        else V[k] -= X[i][j];
      }
    V[k] += X[P][S];
    k++;
    
    
    vec res = gauss_jordan(M,V,cnt);
    if( res.empty() ) cout << "NO" << endl;
    else {
      if( check(res) ){
        for(int i=0;i<cnt;i++)
          cout << (int)round(res[i]) << endl;
      } else
        cout << "NO" << endl;
    }
  }
}