#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<vector<long long>> a(n, vector<long long>(n));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (long long i = 1; i < n; i++) {
    for (long long j = 1; j < n; j++) {
      if (((a[i][j] - a[i][j - 1]) != (a[i - 1][j] - a[i - 1][j - 1])) || ((a[i][j] - a[i - 1][j]) != (a[i][j - 1] - a[i - 1][j - 1]))) {
        return cout << "No\n", 0;
      }
    }
  }
  long long mn = 1e18 + 9, si = 0, sj = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (a[i][j] < mn) {
        si = i; sj = j;
        mn = a[i][j];
      }
    }
  }
  vector<long long> aa(n), bb(n);
  bb[0] = 0;
  for (long long j = 1; j < n; j++) {
    bb[j] = a[0][j] - a[0][j - 1] + bb[j - 1];
  }
  mn = *min_element(bb.begin(), bb.end());
  for (int i = 0; i < n; i++) bb[i] -= mn;
  for (long long i = 0; i < n; i++) {
    aa[i] = a[i][0] - bb[0];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      assert(aa[i] >= 0 && bb[j] >= 0 && a[i][j] == bb[j] + aa[i]);
    }
  }
  cout << "Yes\n";
  for (long long i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << aa[i];
  }
  cout << '\n';
  for (long long i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << bb[i] << " ";
  }
  cout << '\n';
  return 0;
}

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2")
#pragma GCC optimize("unroll-loops")
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define req(i,a,b) for(int i=(a);i>=(b);--i)
#define rep_(i,a,b) for(int i=(a);i<(b).size();++i)
#define F(a) rep(a,1,n)
#define M(a,b) memset(a,b,sizeof a)
#define DC int T;cin>>T;while(T--)
#define ll long long
#define Z(a,b) sort(a+1,a+b+1)
using namespace std;
const unsigned _mod=998244353;
const unsigned mod=3;
const ll infi=0x3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
void rd(auto &x){x=0;int f=1;char ch=getchar();while(ch<48||ch>57){if(ch==45)f=-1;ch=getchar();}while(ch>=48&&ch<=57)x=x*10+ch-48,ch=getchar();x*=f;}
ll ksm(ll x,ll y=mod-2,ll m=mod){ll ret=1;while(y){if(y&1)ret=ret*x%m;y>>=1ll;x=x*x%m;}return ret;}
ll qpow(ll x,ll y=2){ll ret=1;while(y>0){if(y&1ll)ret=ret*x;y>>=1ll;x=x*x;}return ret;}
/*
    [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
    [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
    [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
*/
int n,dep[200010],rt,cnt,E[200010],dis[200010];
vector<int> T[200010];
bool vis[200010];
bool cmp(int x,int y){return dep[x]<dep[y];}
void getdis(int u,int fa) {for (int v:T[u]) if (v!=fa) dis[v]=dis[u]+1,getdis(v,u);}
void _dfs(int x){
	if (T[x].size()==1) dep[x]=1;
	for (int u:T[x]) if (!vis[u]) vis[u]=1,_dfs(u),dep[x]=max(dep[u]+1,dep[x]);
}
void dfs(int x){
	cnt++,E[x]=cnt;
	for(int u:T[x]) if (!vis[u]) vis[u]=1,dfs(u),cnt++;
}
int main()
{
	cin>>n;
	rep(i,1,n-1)
	{
		int a,b;
		rd(a),rd(b);
		T[a].push_back(b),T[b].push_back(a);
	}
	getdis(1,0);rt=1;
	F(i) if (dis[i]>=dis[rt]) rt=i;
	vis[rt]=1;
	_dfs(rt);
	F(i) sort(T[i].begin(),T[i].end(),cmp);
	M(vis,0);
	vis[rt]=1;
	dfs(rt);
	F(i) cout<<E[i]<<' ';
	return 0;
}