#include <bits/stdc++.h>
using namespace std;
int a[310][310];
int n, m;
inline int getmax(int x, int y) { return x > y ? x : y; }
int update(int x, int &cap) {
  if (~cap && x != cap) return 1;
  cap = x;
  return 0;
}
void conduct() {
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  int k = -1;
  for (int i = 1; i < n; ++i) {
    int inc = -1, dec = -1;
    for (int j = 0; j < m; ++j) {
      int ret = a[i - 1][j] < a[i][j] ? update(a[i][j] - a[i - 1][j], inc)
                                      : update(a[i - 1][j] - a[i][j], dec);
      if (ret) {
        printf("NO\n");
        return;
      }
    }
    if (~inc && ~dec) {
      if (~k && k != inc + dec) {
        printf("NO\n");
        return;
      }
      k = inc + dec;
    }
  }
  int mst = -1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) mst = getmax(mst, a[i][j]);
  if (~k && mst >= k) {
    printf("NO\n");
    return;
  }
  if (!~k) k = mst + 1;
  printf("YES\n");
  printf("%d\n", k);
  long long cur = 0LL;
  cout << cur << " ";
  for (int i = 1; i < n; ++i) {
    cur += ((long long)a[i][0] - a[i - 1][0] + k) % k;
    cout << cur << " ";
  }
  printf("\n");
  for (int i = 0; i < m; ++i) printf("%d ", a[0][i]);
  printf("\n");
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) conduct();
  return 0;
}
