
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

template <typename T>
void print(vector<T>& x) {
    int N = x.size();
    REP(i, N) {
        if (i > 0) cout << " ";
        cout << x[i];
    }
    cout << "\n";
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n; cin >> n;
    vector<vll> v(n, vll(n));
    REP(i, n) REP(j, n) cin >> v[i][j];

    vll y;
    REP(i, n) {
        y.eb(*min_element(ALL(v[i])));
    }

    debug(y)

    vll x;
    FOR(i, 0, n) {
        ll tmp = v[0][i] - y[0];
        REP(j, n) {
            if (tmp != v[j][i] - y[j]) {
                print("No");
                return 0;
            }
        }
        x.eb(tmp);
    }

    print("Yes");
    print(y);
    print(x);
}

#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define MAXN 200005
#define max_num 1000000
#define LL long long
using namespace std;
int n, m;
int l[MAXN], r[MAXN];
int main()
{
    while(cin >> n >> m)
    {
        if(m < 0 || m == n || (m == n - 1 && n - 1 > 0))
        {
            puts("-1");
            continue;
        }
        if(n == 1)
        {
            puts("1 2");
            continue;
        }
        int num_w = n - m - 2;
        int now = max_num;
        for(int i = 0; i < num_w; i++)
        {
            r[i] = now;
            now--;
            l[i] = now;
            now--;
        }
        l[num_w] = 1;
        r[num_w] = (m + 2 + 1) * 2;
        now = (m + 2) * 2 - 1;
        for(int i = num_w + 1; i < n; i++)
        {
            r[i] = now;
            now--;
            l[i] = now;
            now--;
        }
        for(int i = 0; i < n; i++)
        {
            printf("%d %d\n", l[i], r[i]);
        }
    }
    return 0;
}