#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(),(x).end() #define inf 1e18 using namespace std; typedef long long llint; typedef long long ll; typedef pair P; ll n, m; int l[3005], r[3005], a[3005]; vector

vec; priority_queue

Q, Q2; priority_queue, greater

> Q3; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; rep(i, 1, n){ cin >> l[i] >> a[i] >> r[i]; if(l[i] > r[i]) swap(l[i], r[i]); vec.push_back(P(l[i], r[i])); } sort(a+1, a+n+1); sort(all(vec)); reverse(all(vec)); ll ans = -inf; rep(i, 0, n){ int cnt = 0; while(Q2.size()) Q2.pop(); while(Q3.size()) Q3.pop(); ll sum = 0, pos = 0; for(int j = i; j >= 1; j--){ while(pos < n && vec[pos].first > a[j]) Q2.push(P(vec[pos].second, vec[pos].first)), pos++; if(Q2.size() == 0) goto end; sum += Q2.top().first; Q2.pop(); } while(pos < n) Q3.push(P(vec[pos].second, vec[pos].first)), pos++; while(Q2.size()) Q3.push(Q2.top()), Q2.pop(); for(int j = i+1; j <= n; j++){ while(Q3.size() && Q3.top().first < a[j]) cnt++, Q3.pop(); if(cnt == 0) goto end; sum += a[j]; cnt--; } chmax(ans, sum); if(ans >= m) break; end:; } if(ans < 0) cout << "NO" << endl; else{ cout << "YES" << endl; if(ans >= m) cout << "KADOMATSU!" << endl; else cout << "NO" << endl; } return 0; }