/*input
10
6 7 5 18 2
3 8 1 6 3
7 2 8 7 7
6 3 3 4 7
12 8 9 15 9
9 8 6 1 10
12 9 7 8 2
10 3 17 4 10
3 1 3 19 3
3 14 7 13 1
*/
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<vector<int> >v;
int get(int msk, int i) {
	int mn = mod;
	for (int bit = 0; bit < 5; bit++) {
		if (msk >> bit & 1) {
			mn = min(mn, v[i][bit]);
		}
	}
	return mn;
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	vector<int>best(1 << 5, -1);
	for (int i = 0; i < n; i++) {
		vector<int>cand;
		for (int j = 0; j < 5; j++) {
			int a;
			cin >> a;
			cand.pb(a);
		}
		v.pb(cand);

		for (int msk = 0; msk < 1 << 5; msk++) {
			if (best[msk] == -1) {
				best[msk] = i;
			} else if (get(msk, i) > get(msk, best[msk])) {
				best[msk] = i;
			}
		}
	}

	int ans = 0;
	for (int a = 0; a < 1 << 5; a++) {
		for (int b = a; b >= 0; b = (b - 1) & a) {
			int msk1 = b;
			int msk2 = a ^ b;
			int msk3 = ((1 << 5) - 1) ^ a;

			vector<int>mx(5);
			for (int idx : {best[msk1], best[msk2], best[msk3]}) {
				for (int i = 0; i < 5; i++) {
					mx[i] = max(mx[i], v[idx][i]);
				}
			}

			int mn = mod;
			for (int i = 0; i < 5; i++) {
				mn = min(mn, mx[i]);
			}
			ans = max(ans, mn);

			if (b == 0) {
				break;
			}
		}
	}

	cout << ans << "\n";
	return 0;
}
#include<bits/stdc++.h>
#define DONTSYNC ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now!
#define TEST unsigned long long T; cin>>T; while(T--)  //loop over each testcase
#define endl "\n"
#define fori(a,start,end) for(int a=start;a<end;a++)
#define forll(a,start,end) for(long long a=start;a<end;a++)
#define forull(a,start,end) for(unsigned long long a=start;a<end;a++)
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define fi first
#define se second
using namespace std;

void solve(){
    /* code */
    int n; cin>>n;
    vector<vector<int>> mat(n,vector<int>(n));
    int mini=0,minj=0;
    fori(i,0,n){
        fori(j,0,n){
            cin>>mat[i][j];
            if(mat[i][j]<mat[mini][minj]) mini=i,minj=j;
        }
    }
    vector<int> B(n);
    vector<int> A(n);
    fori(i,0,n){
        if(!i) B[i]=0;
        else{
            B[i]=mat[0][i]-mat[0][0];
        }

        if(!i) A[i]=0;
        else{
            A[i]=mat[i][0]-mat[0][0];
        }
    }
    
    fori(i,1,n){
        fori(j,1,n){
            if(B[j]!=mat[i][j]-mat[i][0]) 
            {cout<<"No"<<endl;return;}
            if(A[i]!=mat[i][j]-mat[0][j]) 
            {cout<<"No"<<endl;return;}
        }
    }cout<<"Yes"<<endl;
    fori(i,0,n){
        cout<<A[i]-A[mini]<<' ';
    }  cout<<endl;
    fori(i,0,n){
        cout<<B[i]-B[minj]+mat[mini][minj]<<' ';
    }  cout<<endl;
}

int main()
{
    DONTSYNC;
    // TEST
    solve();
    return 0;
}
