#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#define M 100001

int n, m, pthn, ans[M], head[M];
struct Edge {
	int nxt, to, w;
}pth[M << 2];

void add(int from, int to, int w) {
	pth[++pthn].to = to, pth[pthn].nxt = head[from];
	pth[pthn].w = w, head[from] = pthn;
}

void dfs(int u, int now, int last) {
	if (now == -1 && last == -1) ans[u] = 1;
	else if (now == last) ans[u] = now + 1;
	else if (now != last) ans[u] = now;
	if (ans[u] > n) ans[u] = 1;
	for (int i = head[u]; i; i = pth[i].nxt) {
		int v = pth[i].to;
		if (ans[v]) continue;
    dfs(v, pth[i].w, ans[u]);
	}
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1, u, v, w; i <= m; ++i) {
		scanf("%d %d %d", &u, &v, &w);
		add(u, v, w), add(v, u, w);
	}
	dfs(1, -1, -1);
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	return 0;
}
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(0);
#define tie cin.tie(NULL);
#define Inf (1LL<<62)
#define inf (1<<30)
#define ll long long
#define pr pair<int,int>
#define pb push_back
#define fr0(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define no cout<<"No\n";
#define yes cout<<"Yes\n";
#define mp make_pair
#define nl cout<<"\n";
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define case(cs,n) printf("Case #%d: %lld\n",cs,n)
const int mx=2e5;
const ll mod=100000007;
using namespace std;
vector<ll>a(500,Inf),b(500,Inf);
ll c[500][500];
bool mat(int n)
{
	int i,j;
	fr0(i,n) b[0]=min(c[i][0],b[0]);
	fr0(i,n) a[i]=c[i][0]-b[0];
	fr1(j,n-1)
	{
		b[j]=c[0][j]-a[0];
		fr1(i,n-1)
		{
			if(c[i][j]-a[i]!=b[j]) return 0;
		}
	}
	return 1;
}
int main()
{
	io tie
	int n,i,j;
	cin>>n;
	
	fr0(i,n) fr0(j,n) cin>>c[i][j];
	if(mat(n))
	{
		yes
		fr0(i,n) cout<<a[i]<<' '; nl
		fr0(i,n) cout<<b[i]<<' '; nl
	}
	else no
}