#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<ll> A(N), P(N), X(N);
    REP(i, 0, N) cin >> A[i] >> P[i] >> X[i];

    ll ans = 1LL << 60;

    vector<int> I(N);
    iota(ALL(I), 0); sort(ALL(I), [&](auto l, auto r) { return A[l] < A[r]; });

    for (auto i : I) {
        if (X[i] - A[i] > 0) {
            ans = min(ans, P[i]);
        }
    }
    if (ans < (1LL << 60)) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define io ios::sync_with_stdio(false); cin.tie(0)

int main()
{
    io;
    int n; cin >> n;
    vector<int> a(n), b(n);
    vector<vector<int>> c(n, vector<int>(n, 0));
    rep(i, n) rep(j, n) {
        cin >> c[i][j];
    }
    b = c[0];
    a[0] = 0;
    bool flag = true;
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < n; ++j) {
            int diff = c[i][0] - c[0][0];
            if (c[i][j] - c[0][j] != diff) {
                flag = false;
                break;
            }
            a[i] = diff;
        }
    }
    
    int mn = *min_element(a.begin(), a.end());
    if (mn < 0) {
        rep(i, n) {
            a[i] -= mn;
            b[i] += mn;
            if (b[i] < 0) {
                flag = false;
                break;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
        rep(i, n) {
            cout << a[i];
            if (i != n-1) cout << " ";
        }
        cout << endl;
        rep(i, n) {
            cout << b[i];
            if (i != n-1) cout << " ";
        }
        cout << endl;
    } else cout << "No" << endl;
    return 0;
}