// ABC180-E
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

template <typename T>
T TSP(int s, vector<vector<pair<int, T>>>& G, const T INF = 1e9) {
    int V = G.size();
    vector<vector<T>> dp(1 << V, vector<T>(V, INF));
    dp[0][s] = 0;
    for (int bit = 0; bit < 1 << V; bit++) {
        for (int v = 0; v < V; v++) {
            for (auto p : G[v]) {
                int to = p.first, dist = p.second;
                if (bit & 1 << to) continue;
                dp[bit | 1 << to][to] =
                    min(dp[bit | 1 << to][to], dp[bit][v] + dist);
            }
        }
    }
    return dp[(1 << V) - 1][s];
}

signed main() {
    int n;
    cin >> n;
    int x[n], y[n], z[n];
    rep(i, n) {
        cin >> x[i] >> y[i] >> z[i];
    }
    vector<vector<pair<int, ll>>> G(n);
    rep(i, n) {
        rep(j, n) {
            G[i].emplace_back(
                j, abs(x[i] - x[j]) + abs(y[i] - y[j]) + max(0, z[j] - z[i]));
        }
    }
    cout << TSP(0, G, LINF) << 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)

void print_vec(const vector<int>& vec) {
    int n = vec.size();
    rep(i, n) {
        cout << vec[i];
        if (i != n-1) cout << " ";
    }
    cout << endl;
}

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;
        print_vec(a);
        print_vec(b);
    } else cout << "No" << endl;

    return 0;
}