func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   using pii = pair<long long, long long>;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long q;     cin >> q;     while (q--) {       long long n, m;       cin >> n >> m;       vector<pair<long long, pii>> a;       long long len = 0;       for (long long i = 0; i < n; i++) {         long long x, y, z;         cin >> x >> y >> z;         if (i > 0 && x == a[len - 1].first) {           a[len - 1].second.first = max(a[len - 1].second.first, y);           a[len - 1].second.second = min(a[len - 1].second.second, z);         } else {           a.push_back({x, {y, z}});           len++;         }       }       n = len;       long long low = m, high = m, curt = 0;       long long pos = 1;       for (long long i = 0; i < n; i++) {         long long t = a[i].first, l = a[i].second.first, h = a[i].second.second;         if (l > h) {           pos = 0;           break;         }         low -= t - curt;         high += t - curt;         if (low > h || high < l) {           pos = 0;           break;         }         low = max(l, low);         high = min(h, high);         curt = t;       }       if (pos)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }   