#include using namespace std; using ll = long long; #define all(x) begin(x), end(x) #define len(x) int((x).size()) template inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } else { return false; } } template inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } else { return false; } } constexpr int N = 2e5 + 10; int n, a[N], b[N], ord[N]; ll t[N]; struct Node { int l; mutable int r, L, R; bool operator<(Node x) const { return l < x.l; } }; set odt; auto Split(int x) { auto it = prev(odt.upper_bound({.l = x})); if (it->l == x) return it; odt.insert(next(it), {x, it->r, it->R + x - it->r, it->R}); it->r = x - 1, it->R = it->L + it->r - it->l; return next(it); } void Proc() { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i] >> t[i]; iota(all(ord), 0); sort(ord + 1, ord + n + 1, [&](int x, int y) { return t[x] < t[y]; }); odt.clear(); for (int i = 1; i <= n; ++i) odt.insert(end(odt), {i, i, a[i], a[i]}); ll s = 0; for (int ii = 1; ii <= n; ++ii) { int i = ord[ii]; if (i > 1) Split(i - 1); if (i < n) Split(i + 1); auto it = Split(i); s += abs(it->L - b[i]); it = odt.erase(it); if (a[i] < b[i]) { int lim = b[i] + 1; while (it != end(odt) && it->L < lim) { s += ll(lim - it->L) * (it->r - it->l + 1); lim += it->r - it->l + 1; it = odt.erase(it); } odt.insert(it, {i, i + lim - 1 - b[i], b[i], lim - 1}); } else { int lim = b[i] - 1; while (it != begin(odt) && (--it)->R > lim) { s += ll(it->R - lim) * (it->r - it->l + 1); lim -= it->r - it->l + 1; it = odt.erase(it); } odt.insert(it, {i + lim + 1 - b[i], i, lim + 1, b[i]}); } if (s > t[i]) { cout << "No\n"; return; } } cout << "Yes\n"; } int main() { freopen("move.in", "r", stdin); freopen("move.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(nullptr); cin.exceptions(ios::failbit); int _, t; cin >> _ >> t; for (int _ = 1; _ <= t; ++_) Proc(); }