#include using namespace std; typedef long long ll; typedef pair pii; #define pb push_back #define all(a) a.begin(), a.end() #define sz(a) ((int)a.size()) #ifdef Doludu template ostream& operator << (ostream &o, vector vec) { o << "{"; int f = 0; for (T i : vec) o << (f++ ? " " : "") << i; return o << "}"; } void bug__(int c, auto ...a) { cerr << "\e[1;" << c << "m"; (..., (cerr << a << " ")); cerr << "\e[0m" << endl; } #define bug_(c, x...) bug__(c, __LINE__, "[" + string(#x) + "]", x) #define bug(x...) bug_(32, x) #define bugv(x...) bug_(36, vector(x)) #define safe bug_(33, "safe") #else #define bug(x...) void(0) #define bugv(x...) void(0) #define safe void(0) #endif const int mod = 998244353, N = 300005; int main() { ios::sync_with_stdio(false), cin.tie(0); int n, d; cin >> n >> d; vector > arr(n); int tot0 = 0, tot2 = 0; for (auto &[a, b, c] : arr) cin >> a >> b >> c, tot0 += a, tot2 += c; vector mnl(1 << n, 1 << 30), mnr(1 << n, 1 << 30); for (int s = 0; s < 1 << n; ++s) if (__builtin_popcount(s) == n / 2) { vector ord; for (int i = 0; i < n; ++i) if (s >> i & 1) { ord.pb(i); } do { int x = 0, y = 0, z = 0, cur2 = 0; for (int i : ord) { x += arr[i][0]; y = max(x, y) + arr[i][1]; z = max(y, z) + arr[i][2]; cur2 += arr[i][2]; } if (z + tot2 - cur2 <= d) { mnl[s] = min(mnl[s], y); } } while (next_permutation(all(ord))); } for (int s = 0; s < 1 << n; ++s) if (__builtin_popcount(s) == (n + 1) / 2) { vector ord; for (int i = 0; i < n; ++i) if (s >> i & 1) { ord.pb(i); } do { int x = 0, y = 0, z = 0, cur0 = 0; for (int i : ord) { z += arr[i][2]; y = max(y, z) + arr[i][1]; x = max(x, y) + arr[i][0]; cur0 += arr[i][0]; } if (x + tot0 - cur0 <= d) { mnr[s] = min(mnr[s], y); } } while (next_permutation(all(ord))); } for (int s = 0; s < 1 << n; ++s) if (__builtin_popcount(s) == n / 2) { if (mnl[s] <= d - mnr[s ^ ((1 << n) - 1)]) { cout << "Yes\n"; return 0; } } cout << "No\n"; }