#include <bits/stdc++.h>
using namespace std;
int n, m;
long long w[105][105];
long long k;
long long a[105];
long long b[105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> w[i][j];
    }
  }
  k = -1;
  for (int j = 0; j + 1 < m; j++) {
    long long minus = 1;
    long long plus = -1;
    bool zero = false;
    for (int i = 0; i < n; i++) {
      long long diff = w[i][j + 1] - w[i][j];
      if (diff < 0) {
        if (minus == 1) {
          minus = diff;
        }
        if (diff != minus) {
          cout << "NO\n";
          return 0;
        }
      }
      if (diff > 0) {
        if (plus == -1) {
          plus = diff;
        }
        if (diff != plus) {
          cout << "NO\n";
          return 0;
        }
      }
      if (diff == 0) {
        zero = true;
      }
    }
    if (minus != 1 && plus != -1) {
      if (k == -1) {
        k = plus - minus;
      }
      if (plus - minus != k) {
        cout << "NO\n";
        return 0;
      }
    }
    if (zero && (plus != -1 || minus != 1)) {
      cout << "NO\n";
      return 0;
    }
  }
  if (k == -1) {
    k = 2e9;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (w[i][j] >= k) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  cout << k << "\n";
  for (int i = 0; i < n; i++) {
    cout << w[i][0] << " ";
  }
  cout << "\n";
  long long sum = 0;
  cout << 0 << " ";
  for (int j = 1; j < m; j++) {
    long long diff = (w[0][j] - w[0][j - 1] + k) % k;
    sum = (sum + diff + k) % k;
    cout << sum << " ";
  }
  cout << "\n";
  return 0;
}
