#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
    ll n,w;
    cin >> n >> w;
    Vl v(200010);
    rep(i,n){
        ll x,y,z;
        cin >> x >> y >> z;
        v[x]+=z;v[y]-=z;
    }
    bool b=1;
    rep(i,200005){
        v[i+1]+=v[i];
        if(v[i+1]>w||v[i]>w)b=0;
        //if(i<=100)cout << v[i+1] << endl;
    }
    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


//================code===================//

//#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define ld long double
#define fa(i,a,b) for(LL i=(a);i<(LL)(b);++i)
#define fd(i,a,b) for(LL i=(a);i>(LL)(b);--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define micro 0.000001

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#else
#define AT
#define AE
#define ce(t)
#define __popcnt __builtin_popcountll
#endif

pair <int, int> vu[9] = { {0,1},{1,0},{0,-1} ,{-1,0},{0,0},{1,0}, {-1,1} , {1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl a, setl b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl a, setl b) { return a.second > b.second; } };

const int max_v = 5e2 + 7;
const int INF = 1e9 + 7;
const LL LNF = (LL)5e18 + 7ll;
const LL mod = 1e9 + 7;

int arr[max_v][max_v];
int col[max_v];
int ans[max_v];

int main()
{
#ifdef OHSOLUTION
	freopen("input.txt", "r", stdin);
#endif	
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	int n; ci(n);
	fa(i, 0, n) fa(j, 0, n)ci(arr[i][j]);

	fa(j, 0, n)
	{
		col[j] = arr[0][j];
		fa(i, 1, n) ckmin(col[j], arr[i][j]);
	}

	int row = arr[0][0];
	fa(i, 0, n) ckmin(row, arr[0][i]);

	bool ck = true;
	fa(i, 0, n)
	{
		if (col[i] >= arr[0][i] - row) col[i] = arr[0][i] - row;
		else ck = false;
	}
	ans[0] = row;

	fa(i, 1, n)
	{
		int row = arr[i][0];
		fa(j, 1, n) ckmin(row, arr[i][j]);
		ans[i] = row;
		fa(j, 0, n)
		{
			if (col[j] != arr[i][j] - row) ck = false;
		}
	}

	if (ck)
	{
		co("Yes\n");

		fa(i, 0, n) co(ans[i] << " ");
		co("\n");
		fa(i, 0, n) co(col[i] << " ");
	}
	else co("No\n");

	return 0;
}