#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cerr << a[i] << " "
#define debug_vector(a) for(auto it : a)cout << it << " "
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define inf 1000000000
#define mod 1000000007
ll power(ll a , ll b)
{
ll prod = 1;
while(b)
{
if(b&1)
prod = (prod*a)%mod;
a = (a*a)%mod;
b >>= 1;
}
return prod;
}
int main()
{
int t;
cin >> t;
while(t--)
{
ll n , m;
cin >> n >> m;
ll point1 = m , point2 = m , flag1 = 0 , flag = 0 , cnt = 0;
vector<pair<ll , pair<ll,ll>>> p;
map<ll , vector<pair<ll,ll>>> m1;
for(int i = 0 ; i < n ; i++)
{
ll x , lb , ub;
cin >> x >> lb >> ub;
m1[x].pb({lb , ub});
}
for(auto it : m1)
{
ll max1 = it.ss[0].ss;
ll min1 = it.ss[0].ff;
for(auto it1 : it.ss)
{
// cout << it1.ff << " " << it1.ss << " ";
max1 = min(it1.ss , max1);
min1 = max(it1.ff , min1);
}
// cout << min1 << " " << max1 << endl;
if(min1 <= max1)
{
p.pb({it.ff , {min1 , max1}});
}
else
{
cout << "NO\n";
flag1 = 1;
break;
}
}
if(flag1 == 1)continue;
n = p.size();
// for(auto it : p)
// {
// cout << it.ff << " " << it.ss.ff << " " << it.ss.ss << endl;
// }
int num = 0;
if(p[0].ff == 0)
{
num = 1;
// cout << p[0].ss.ff << " " << p[0].ss.ss << endl;
if(!(m >= p[0].ss.ff && m <= p[0].ss.ss))
{
cout << "NO\n";
flag1 = 1;
}
else
{
point1 = p[0].ss.ff;
point2 = p[0].ss.ss;
}
}
for(int i = num ; i < n ; i++)
{
ll x , lb , ub;
x = p[i].ff;
lb = p[i].ss.ff;
ub = p[i].ss.ss;
ll max1 , min1;
// cout << point1 << " " << point2 << endl;
if(i == 0)
max1 = max(x + point1 , x + point2), min1 = min(point2 - x , point1 - x);
else
{
x -= p[i-1].ff;
max1 = max(x + point1 , x + point2), min1 = min(point2 - x , point1 - x);
}
// cout << max1 << " " << min1 << endl;
ll max2 = max1 , min2 = min1;
flag = 0;
if(ub == lb){
if(ub <= max1 && ub > min1)
{
flag = 1;
max2 = ub;
}
if(lb < max1 && lb >= min1)
{
flag = 1;
min2 = lb;
}
}
else
{
if(ub <= max1 && ub >= min1)
{
flag = 1;
max2 = ub;
}
if(lb <= max1 && lb >= min1)
{
flag = 1;
min2 = lb;
}
}
if(flag == 0)
{
cout << "NO\n";
flag1 = 1;
break;
}
point1 = max2;
point2 = min2;
}
if(flag1 == 0)
{
cout << "YES\n";
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CiNkZWZpbmUgZGVidWcoeCkgY291dCA8PCAjeCA8PCAiID0gIiA8PCB4IDw8ICdcbicKI2RlZmluZSBkZWJ1Z19hcnIoYSAsIG4pIGZvcihpbnQgaSA9IDAgOyBpIDwgbiA7IGkrKyljZXJyIDw8IGFbaV0gPDwgIiAiCiNkZWZpbmUgZGVidWdfdmVjdG9yKGEpIGZvcihhdXRvIGl0IDogYSljb3V0IDw8IGl0IDw8ICIgIgojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGZmIGZpcnN0CiNkZWZpbmUgc3Mgc2Vjb25kCiNkZWZpbmUgdmkgdmVjdG9yPGludD4KI2RlZmluZSB2bGwgdmVjdG9yPGxsPiAKI2RlZmluZSBpbmYgMTAwMDAwMDAwMAojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CgpsbCBwb3dlcihsbCBhICwgbGwgYikKewogICAgbGwgcHJvZCA9IDE7CiAgICB3aGlsZShiKQogICAgewogICAgICAgIGlmKGImMSkKICAgICAgICBwcm9kID0gKHByb2QqYSklbW9kOwogICAgICAgIGEgPSAoYSphKSVtb2Q7CiAgICAgICAgYiA+Pj0gMTsKICAgIH0KICAgIHJldHVybiBwcm9kOwp9CmludCBtYWluKCkKewogICAgaW50IHQ7CiAgICBjaW4gPj4gdDsKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgICAgICBsbCBuICwgbTsKICAgICAgICBjaW4gPj4gbiA+PiBtOwogICAgICAgIGxsIHBvaW50MSA9IG0gLCBwb2ludDIgPSBtICwgZmxhZzEgPSAwICwgZmxhZyA9IDAgLCBjbnQgPSAwOwogICAgICAgIHZlY3RvcjxwYWlyPGxsICwgcGFpcjxsbCxsbD4+PiBwOwogICAgICAgIG1hcDxsbCAsIHZlY3RvcjxwYWlyPGxsLGxsPj4+IG0xOwogICAgICAgIGZvcihpbnQgaSA9IDAgOyBpIDwgbiA7IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIGxsIHggLCBsYiAsIHViOwogICAgICAgICAgICBjaW4gPj4geCA+PiBsYiA+PiB1YjsKICAgICAgICAgICAgbTFbeF0ucGIoe2xiICwgdWJ9KTsKICAgICAgICB9CgogICAgICAgIGZvcihhdXRvIGl0IDogbTEpCiAgICAgICAgewoKICAgICAgICAgICAgbGwgbWF4MSA9IGl0LnNzWzBdLnNzOwogICAgICAgICAgICBsbCBtaW4xID0gaXQuc3NbMF0uZmY7CgogICAgICAgICAgICBmb3IoYXV0byBpdDEgOiBpdC5zcykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgLy8gY291dCA8PCBpdDEuZmYgPDwgIiAiIDw8IGl0MS5zcyA8PCAiICI7CiAgICAgICAgICAgICAgICBtYXgxID0gbWluKGl0MS5zcyAsIG1heDEpOwogICAgICAgICAgICAgICAgbWluMSA9IG1heChpdDEuZmYgLCBtaW4xKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAvLyBjb3V0IDw8IG1pbjEgPDwgIiAiIDw8IG1heDEgPDwgZW5kbDsKICAgICAgICAgICAgaWYobWluMSA8PSBtYXgxKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwLnBiKHtpdC5mZiAsIHttaW4xICwgbWF4MX19KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgIk5PXG4iOwogICAgICAgICAgICAgICAgZmxhZzEgPSAxOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgfQogICAgICAgIGlmKGZsYWcxID09IDEpY29udGludWU7CiAgICAgICAgbiA9IHAuc2l6ZSgpOwoKICAgICAgICAvLyBmb3IoYXV0byBpdCA6IHApCiAgICAgICAgLy8gewogICAgICAgIC8vICAgICBjb3V0IDw8IGl0LmZmIDw8ICIgIiA8PCBpdC5zcy5mZiA8PCAiICIgPDwgaXQuc3Muc3MgPDwgZW5kbDsKICAgICAgICAvLyB9CiAgICAgICAgaW50IG51bSA9IDA7CiAgICAgICAgaWYocFswXS5mZiA9PSAwKQogICAgICAgIHsKICAgICAgICAgICAgbnVtID0gMTsKICAgICAgICAgICAgLy8gY291dCA8PCBwWzBdLnNzLmZmIDw8ICIgIiA8PCBwWzBdLnNzLnNzIDw8IGVuZGw7CiAgICAgICAgICAgIGlmKCEobSA+PSBwWzBdLnNzLmZmICYmIG0gPD0gcFswXS5zcy5zcykpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgIk5PXG4iOwogICAgICAgICAgICAgICAgZmxhZzEgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcG9pbnQxID0gcFswXS5zcy5mZjsKICAgICAgICAgICAgICAgIHBvaW50MiA9IHBbMF0uc3Muc3M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgfQogICAgICAgIGZvcihpbnQgaSA9IG51bSA7IGkgPCBuIDsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgbGwgeCAsIGxiICwgdWI7CiAgICAgICAgICAgIHggPSBwW2ldLmZmOwogICAgICAgICAgICBsYiA9IHBbaV0uc3MuZmY7CiAgICAgICAgICAgIHViID0gcFtpXS5zcy5zczsKICAgICAgICAgICAgbGwgbWF4MSAsIG1pbjE7CiAgICAgICAgICAgIC8vIGNvdXQgPDwgcG9pbnQxIDw8ICIgIiA8PCBwb2ludDIgPDwgZW5kbDsKICAgICAgICAgICAgaWYoaSA9PSAwKQogICAgICAgICAgICAgICAgbWF4MSA9IG1heCh4ICsgcG9pbnQxICAsIHggKyBwb2ludDIpLCBtaW4xID0gbWluKHBvaW50MiAtIHggLCBwb2ludDEgLSB4KTsKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB4IC09IHBbaS0xXS5mZjsKICAgICAgICAgICAgICAgIG1heDEgPSBtYXgoeCArIHBvaW50MSAgLCB4ICsgcG9pbnQyKSwgbWluMSA9IG1pbihwb2ludDIgLSB4ICwgcG9pbnQxIC0geCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgICAgIC8vIGNvdXQgPDwgbWF4MSA8PCAiICIgPDwgbWluMSA8PCBlbmRsOwogICAgICAgICAgICBsbCBtYXgyID0gbWF4MSAsIG1pbjIgPSBtaW4xOwogICAgICAgICAgICBmbGFnID0gMDsKICAgICAgICAgICAgaWYodWIgPT0gbGIpewogICAgICAgICAgICAgICAgaWYodWIgPD0gbWF4MSAmJiB1YiA+IG1pbjEpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZmxhZyA9IDE7CiAgICAgICAgICAgICAgICAgICAgbWF4MiA9IHViOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYobGIgPCBtYXgxICYmIGxiID49IG1pbjEpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZmxhZyA9IDE7CiAgICAgICAgICAgICAgICAgICAgbWluMiA9IGxiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYodWIgPD0gbWF4MSAmJiB1YiA+PSBtaW4xKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGZsYWcgPSAxOwogICAgICAgICAgICAgICAgICAgIG1heDIgPSB1YjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmKGxiIDw9IG1heDEgJiYgbGIgPj0gbWluMSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBmbGFnID0gMTsKICAgICAgICAgICAgICAgICAgICBtaW4yID0gbGI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgICAgIGlmKGZsYWcgPT0gMCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY291dCA8PCAiTk9cbiI7CiAgICAgICAgICAgICAgICBmbGFnMSA9IDE7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb2ludDEgPSBtYXgyOwogICAgICAgICAgICBwb2ludDIgPSBtaW4yOwogICAgICAgIH0KICAgICAgICBpZihmbGFnMSA9PSAwKQogICAgICAgIHsKICAgICAgICAgICAgY291dCA8PCAiWUVTXG4iOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9