#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <sstream>
using namespace std;
 
void solve() {
	int n, w;
	cin >> n >> w;
	set<long long> time;
	map<long long, long long > add;
	map<long long, long long> rem;
	for(int i = 0; i < n; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		add[x] += z;
		rem[y] += z;
		time.insert(x);
		time.insert(y);
	}
	set<long long>::iterator it;
	long long total = 0LL;
	string ans = "Yes";
	for(it = time.begin(); it != time.end(); ++it) {
		long long x = (long long) *it;
		if(add[x] > 0) total += add[x];
		if(rem[x] > 0) total -= rem[x];
		if(total > w) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
}
 
int main () {
	int t = 1;
	for(int tt = 0; tt < t; tt++) solve();
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;


#define FOR(i,a,b) for(int i=a; i <=(b); i++)
#define ROF(i,a,b) for(int i=a; i >=(b); i--)
#define loop(i,a) for(int i=0; i < (a); i++)
#define rloop(i,a) for(int i=(a-1); i >= 0; i--)
#define MAX(a,b) (a < b) ? (b) : (a)
#define BIGGEST(a,b,c) (MAX(a,b) < c) ? (c) : MAX(a,b)
#define END "\n"
#define pb push_back
#define first ff
#define second ss

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

void solve() {
 
 	int n,k;
 	cin >> n >> k;

 	vector<vector<int>> a(n,vector<int> (n, 0)); 

 	loop(i,n){
 		loop(j,n){
 			cin >> a[i][j];
 		}
 	}

 	// vector<vector<int>> out(n,vector<int> (n+1));
 	vector<int>out;
 	vector<int>ans;
 	for(int i=1; i < n; i++){
 		ans.push_back(i+1);
 	}

 	ll sum=0,cnt=0;
 	do{
 		sum = 0;
 		// for(auto x : ans)cerr << x << " ";
 		// cerr << "\n"; 

 		for(int i=0; i < n-1; i++){
 			sum += a[ans[i]-1][ans[i+1]-1];
 		}
 		sum += (a[0][ans[0]-1]) + (a[ans[ans.size()-1]-1][0]);
 		// cerr << sum << "\n";
 		if(sum == k){
 			cnt++;
 		}
 	}while(next_permutation(ans.begin(),ans.end()));

 	cout << cnt;
}



int main() {
    
    ios_base::sync_with_stdio(false);cin.tie(NULL); 
	solve();
    
        

     cerr<<"\ntime taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
}
