Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.

Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all customers by controlling the temperature of the restaurant.

The restaurant has an air conditioner that has 3 states: off, heating, and cooling. When it's off, the restaurant's temperature remains the same. When it's heating, the temperature increases by 1 in one minute. Lastly, when it's cooling, the temperature decreases by 1 in one minute. Gildong can change the state as many times as he wants, at any integer minutes. The air conditioner is off initially.

Each customer is characterized by three values: $t_i$ — the time (in minutes) when the $i$-th customer visits the restaurant, $l_i$ — the lower bound of their preferred temperature range, and $h_i$ — the upper bound of their preferred temperature range.

A customer is satisfied if the temperature is within the preferred range at the instant they visit the restaurant. Formally, the $i$-th customer is satisfied if and only if the temperature is between $l_i$ and $h_i$ (inclusive) in the $t_i$-th minute.

Given the initial temperature, the list of reserved customers' visit times and their preferred temperature ranges, you're going to help him find if it's possible to satisfy all customers.


-----Input-----

Each test contains one or more test cases. The first line contains the number of test cases $q$ ($1 \le q \le 500$). Description of the test cases follows.

The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 100$, $-10^9 \le m \le 10^9$), where $n$ is the number of reserved customers and $m$ is the initial temperature of the restaurant.

Next, $n$ lines follow. The $i$-th line of them contains three integers $t_i$, $l_i$, and $h_i$ ($1 \le t_i \le 10^9$, $-10^9 \le l_i \le h_i \le 10^9$), where $t_i$ is the time when the $i$-th customer visits, $l_i$ is the lower bound of their preferred temperature range, and $h_i$ is the upper bound of their preferred temperature range. The preferred temperature ranges are inclusive.

The customers are given in non-decreasing order of their visit time, and the current time is $0$.


-----Output-----

For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO".

You can print each letter in any case (upper or lower).


-----Example-----
Input
4
3 0
5 1 2
7 3 5
10 -1 0
2 12
5 7 10
10 16 20
3 -100
100 0 0
100 -50 50
200 100 100
1 100
99 -100 0

Output
YES
NO
YES
NO



-----Note-----

In the first case, Gildong can control the air conditioner to satisfy all customers in the following way:  At $0$-th minute, change the state to heating (the temperature is 0).  At $2$-nd minute, change the state to off (the temperature is 2).  At $5$-th minute, change the state to heating (the temperature is 2, the $1$-st customer is satisfied).  At $6$-th minute, change the state to off (the temperature is 3).  At $7$-th minute, change the state to cooling (the temperature is 3, the $2$-nd customer is satisfied).  At $10$-th minute, the temperature will be 0, which satisfies the last customer. 

In the third case, Gildong can change the state to heating at $0$-th minute and leave it be. Then all customers will be satisfied. Note that the $1$-st customer's visit time equals the $2$-nd customer's visit time.

In the second and the fourth case, Gildong has to make at least one customer unsatisfied.

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting

Amortized analysis

Implementation

Greedy algorithms

Dynamic programming


Solutions:
q = int(input())
for x in range(q):
	(n, m) = [int(x) for x in input().split()]
	cust = []
	bool1 = False
	for y in range(n):
		cust.append([int(x) for x in input().split()])
	poss = (m - cust[0][0], m + cust[0][0])
	t_pre = cust[0][0]
	for y in range(n):
		pref = (cust[y][1], cust[y][2])
		if pref[0] <= poss[1] and poss[0] <= pref[1]:
			temp = [-10, 10]
			if poss[0] <= pref[0] <= poss[1]:
				temp[0] = pref[0]
			else:
				temp[0] = poss[0]
			if poss[0] <= pref[1] <= poss[1]:
				temp[1] = pref[1]
			else:
				temp[1] = poss[1]
		else:
			print('NO')
			bool1 = True
			break
		if y < n - 1:
			t_next = cust[y + 1][0] - t_pre
			poss = (temp[0] - t_next, temp[1] + t_next)
			t_pre = cust[y + 1][0]
	if bool1:
		continue
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	(t, l, h) = ([0], [m], [m])
	for _ in range(n):
		(ti, li, hi) = list(map(int, input().split()))
		t.append(ti)
		l.append(li)
		h.append(hi)
	(maxT, minT) = (m, m)
	for i in range(1, n + 1):
		tDiff = t[i] - t[i - 1]
		achMax = maxT + tDiff
		achMin = minT - tDiff
		if achMax < l[i] or achMin > h[i]:
			print('NO')
			break
		else:
			maxT = min(achMax, h[i])
			minT = max(achMin, l[i])
	else:
		print('YES')


import sys
q = int(input())
g = sys.stdin.readlines()
y = 0
for r in range(q):
	f = True
	(n, m) = map(int, g[y].split())
	y += 1
	line = [(0, m, m)]
	for i in range(n):
		line.append(tuple(map(int, g[y].replace('\n', '').split())))
		y += 1
	line.sort(key=lambda x: x[0])
	f = True
	lp = m
	hp = m
	for i in range(1, n + 1):
		(t, l, h) = line[i]
		tp = line[i - 1][0]
		delta = t - tp
		if lp - delta > h or hp + delta < l:
			print('NO')
			f = False
			break
		lp = max(l, lp - delta)
		hp = min(h, hp + delta)
	if f:
		print('YES')


def intersection(r1, r2):
	if r1[0] > r2[1] or r2[0] > r1[1]:
		return None
	return (max(r1[0], r2[0]), min(r1[1], r2[1]))

def solve(test):
	(temp, costumers) = test
	cur_range = (temp, temp)
	cur_min = 0
	for i in costumers:
		if i[0] == cur_min:
			cur_range = intersection(cur_range, (i[1], i[2]))
			if cur_range is None:
				print('NO')
				return
		else:
			delta = i[0] - cur_min
			cur_range = (cur_range[0] - delta, cur_range[1] + delta)
			cur_range = intersection(cur_range, (i[1], i[2]))
			cur_min = i[0]
			if cur_range is None:
				print('NO')
				return
	print('YES')

def handle_tests():
	number_of_tests = int(input())
	tests = []
	for i in range(number_of_tests):
		costumers = []
		(n, m) = input().split()
		for i in range(int(n)):
			(t, l, h) = input().split()
			costumers.append((int(t), int(l), int(h)))
		tests.append((int(m), costumers))
	for test in tests:
		solve(test)
handle_tests()


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	tlh = [list(map(int, input().split())) for __ in range(n)]
	now = [m, m]
	a = 0
	t = 0
	for c in tlh:
		time = c[0] - t
		t = c[0]
		lower = max(now[0] - time, c[1])
		upper = min(now[1] + time, c[2])
		if lower > upper:
			print('NO')
			a = 1
			break
		now = [lower, upper]
	if a == 0:
		print('YES')


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(x, y):
	return f(x) // (f(y) * f(x - y))
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	la = []
	for i in range(n):
		(t, a, b) = map(int, input().split())
		la.append([t, a, b])
	ti = 0
	flag = 0
	(k1, k2) = (m, m)
	for (t, a, b) in la:
		z = t - ti
		ti = t
		(k1, k2) = (k1 - z, k2 + z)
		if (a <= k1 <= b or a <= k2 <= b) or (k1 <= a <= k2 or k1 <= b <= k2):
			(k1, k2) = (max(a, k1), min(b, k2))
			continue
		else:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')
c = 56
for i in range(100050):
	c += 56


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	f = 0
	a = k
	b = k
	c = 0
	f = 1
	for i in range(n):
		(t, l, h) = map(int, input().split())
		p = t - c
		a -= p
		b += p
		if b < l or a > h:
			f = 0
		c = t
		a = max(a, l)
		b = min(b, h)
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = []
	l = []
	h = []
	for i in range(n):
		(a, b, c) = map(int, input().split())
		t.append(a)
		l.append(b)
		h.append(c)
	if m + t[0] < l[0] or m - t[0] > h[0]:
		g = 0
		(cl, ch) = (0, 0)
	else:
		g = 1
		(cl, ch) = (max(m - t[0], l[0]), min(m + t[0], h[0]))
	for i in range(1, n):
		(p, q, r) = (t[i] - t[i - 1], l[i], h[i])
		if q > ch + p or r < cl - p:
			g = 0
			break
		else:
			(cl, ch) = (max(cl - p, q), min(ch + p, r))
	if g:
		print('YES')
	else:
		print('NO')


def main(n, m, ts, ls, hs):
	tc = 0
	hc = m
	lc = m
	for i in range(n):
		hc = hc + (ts[i] - tc)
		lc = lc - (ts[i] - tc)
		if ls[i] <= hc and hs[i] >= lc:
			hc = min(hs[i], hc)
			lc = max(ls[i], lc)
			tc = ts[i]
			continue
		return 'NO'
	return 'YES'
q = int(input())
for _ in range(q):
	(n, m) = [int(x) for x in input().split()]
	ts = [0] * n
	ls = [0] * n
	hs = [0] * n
	for i in range(n):
		(ts[i], ls[i], hs[i]) = [int(x) for x in input().split()]
	print(main(n, m, ts, ls, hs))


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def intersection(l1, r1, l2, r2):
	if l1 <= l2:
		if l2 <= r1:
			return (True, l2, min(r1, r2))
		else:
			return (False, 0, 0)
	elif l1 <= r2:
		return (True, l1, min(r1, r2))
	else:
		return (False, 0, 0)
t = I()
for _ in range(t):
	(n, m) = M()
	x = []
	for i in range(n):
		x.append(L())
	x.sort(key=lambda x: (x[0], x[1], x[2]))
	x.append([0, 0, 0])
	l = []
	p = x[0]
	wrong = 0
	for i in range(n + 1):
		if x[i][0] == p[0]:
			w = intersection(x[i][1], x[i][2], p[1], p[2])
			if w[0] == False:
				wrong = 1
				break
			else:
				p[1] = w[1]
				p[2] = w[2]
		else:
			l.append(p)
			p = x[i]
	if wrong:
		print('NO')
	else:
		s = m
		p = [0, m, m]
		for i in range(len(l)):
			P = p[1] - (l[i][0] - p[0])
			Q = p[2] + (l[i][0] - p[0])
			w = intersection(P, Q, l[i][1], l[i][2])
			if w[0] == False:
				print('NO')
				wrong = 1
				break
			else:
				p = [l[i][0], w[1], w[2]]
		if wrong == 0:
			print('YES')


def f():
	(n, m) = map(int, input().split())
	v = []
	for _ in range(n):
		v.append(list(map(int, input().split())))
	tt = 0
	mn = mx = m
	for i in range(n):
		at = v[i][0] - tt
		mn = mn - at
		mx = mx + at
		mn = max(v[i][1], mn)
		mx = min(v[i][2], mx)
		tt = v[i][0]
		if mx < mn:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	print(f())


testcases = int(input())
for j in range(testcases):
	(n, m) = map(int, input().split())
	cust = []
	for s in range(n):
		(t, l, u) = map(int, input().split())
		cust.append((t, l, u))
	cust = sorted(cust, key=lambda x: x[0])
	mleft = 0
	l1 = m - cust[0][0]
	u1 = m + cust[0][0]
	posi = True
	for s in range(n):
		val1 = cust[s]
		if s != 0:
			diff = cust[s][0] - cust[s - 1][0]
			t1 = l1 - diff
			t2 = u1 + diff
		elif s == 0:
			diff = cust[s][0]
			t1 = l1
			t2 = u1
		overlap = False
		if max(t1, val1[1]) <= min(t2, val1[2]):
			overlap = True
			l1 = max(val1[1], t1)
			u1 = min(val1[2], t2)
		if overlap == False:
			posi = False
			break
	if posi == True:
		print('YES')
	else:
		print('NO')


for q in range(int(input())):
	res = 'YES'
	time = 0
	(n, tmp) = map(int, input().split())
	tmp = [tmp, tmp]
	for i in range(n):
		(ti, li, hi) = map(int, input().split())
		yy = ti - time
		make = [tmp[0] - yy, tmp[1] + yy]
		if li > make[1] or hi < make[0]:
			res = 'NO'
		tmp = [max(li, make[0]), min(hi, make[1])]
		time = ti
	print(res)


I = lambda : map(int, input().split())
for _ in range(int(input())):
	f = False
	(n, m) = I()
	L = [tuple(I()) for q in range(n)]
	(t, l, h) = L[-1]
	for i in range(2, n + 1):
		(t2, l2, h2) = L[-i]
		d = t - t2
		t = t2
		l = max(l - d, l2)
		h = min(h + d, h2)
		if l > h:
			f = True
			break
	if f or (m < l - t or m > h + t):
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	curr_l = curr_h = m
	curr_t = 0
	visitors = [list(map(int, input().split())) for _ in range(n)]
	answer = 'yes'
	for (t, l, h) in visitors:
		curr_l = max(l, curr_l - (t - curr_t))
		curr_h = min(h, curr_h + (t - curr_t))
		curr_t = t
		if curr_l > curr_h:
			answer = 'no'
			break
	print(answer)


import math
from collections import deque
from collections import defaultdict
qq = int(input())
while qq > 0:
	qq -= 1
	(n, m) = map(int, input().strip().split(' '))
	arr = []
	for i in range(n):
		(t, l, h) = map(int, input().strip().split(' '))
		arr.append([t, l, h])
	arr.sort(key=lambda k: (k[0], k[1], k[2]))
	s = m - arr[0][0]
	e = m + arr[0][0]
	poss = True
	for i in range(n):
		if arr[i][1] >= s and arr[i][1] <= e or (arr[i][2] >= s and arr[i][2] <= e) or (arr[i][1] <= s and arr[i][2] >= e):
			s = max(s, arr[i][1])
			e = min(e, arr[i][2])
			if i != n - 1:
				s -= arr[i + 1][0] - arr[i][0]
				e += arr[i + 1][0] - arr[i][0]
		else:
			poss = False
			break
	if poss:
		print('YES')
	else:
		print('NO')


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	(n, m) = Ri()
	lis = []
	for i in range(n):
		temp = Ri()
		lis.append(temp)
	lis.sort(key=lambda x: x[0])
	prev = 0
	l = m
	flag = True
	r = m
	for i in range(len(lis)):
		temp = lis[i]
		dif = temp[0] - prev
		l = l - dif
		r = r + dif
		if not max(l, temp[1]) <= min(r, temp[2]):
			flag = False
			break
		l = max(l, temp[1])
		r = min(r, temp[2])
		prev = temp[0]
	if not flag:
		NO()
	else:
		YES()


Q = int(input())
for _ in range(Q):
	_t = 0
	(n, m) = map(int, input().split(' '))
	(lt, ht) = (m, m)
	flag = True
	for i in range(n):
		(t, l, h) = map(int, input().split(' '))
		lt = max(l, lt - (t - _t))
		ht = min(h, ht + (t - _t))
		if lt > ht:
			flag = False
		_t = t
	print('YES' if flag else 'NO')


def solve():
	(n, m) = map(int, input().split())
	t = 0
	mx = mn = m
	LOGIC = True
	while n > 0:
		n -= 1
		(ti, li, hi) = map(int, input().split())
		mx += ti - t
		mn -= ti - t
		t = ti
		if mn <= li and li <= mx or (mn <= hi and hi <= mx) or (li <= mn and mn <= hi) or (li <= mx and mx <= hi):
			mx = min(mx, hi)
			mn = max(mn, li)
		else:
			LOGIC = False
	return LOGIC
q = int(input())
while q > 0:
	q -= 1
	print('YES' if solve() else 'NO')


from collections import defaultdict as dc
from heapq import *
import math
import bisect
import sys
from collections import deque as dq

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p

def check(a, b, x, y):
	if x > b:
		return 0
	if y < a:
		return 0
	return 1

def convert(x):
	if x == 0:
		return 'NO'
	return 'YES'
for _ in range(int(inp())):
	(n, t) = line()
	(mn, mx) = (t, t)
	ans = 1
	p_t = 0
	p = []
	for i in range(n):
		(t, x, y) = line()
		p.append((t, x, y))
	for i in range(n):
		(t, x, y) = p[i]
		time_have = t - p_t
		p_t = t
		mx = min(y, mx + time_have)
		mn = max(x, mn - time_have)
		if check(x, y, mn, mx) == 0:
			ans = 0
			break
	print(convert(ans))


for t in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = []
	for i in range(n):
		a.append(list(map(int, input().split())))
	t0 = 0
	(mi, ma) = (m, m)
	f = True
	for (t, l, h) in a:
		delta = t - t0
		t0 = t
		mi -= delta
		ma += delta
		if mi <= l and ma >= h:
			mi = l
			ma = h
		elif l <= ma <= h and mi <= l:
			mi = l
			ma = ma
		elif l <= ma <= h and l <= mi <= h:
			mi = mi
			ma = ma
		elif ma >= h and l <= mi <= h:
			ma = h
			mi = mi
		else:
			f = False
	if f:
		print('YES')
	else:
		print('NO')


q = int(input())
for z in range(q):
	(n, m) = map(int, input().split())
	maxTemp = m
	minTemp = m
	nowTime = 0
	f = 0
	for x in range(n):
		(t, l, h) = map(int, input().split())
		d = t - nowTime
		maxTemp += d
		minTemp -= d
		if maxTemp >= l and minTemp <= h:
			if minTemp < l:
				minTemp = l
			if maxTemp > h:
				maxTemp = h
		else:
			f = 1
		nowTime = t
	if f == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = b = m
	m = 0
	ans = 'yes'
	for _ in range(n):
		(t, p, q) = map(int, input().split())
		a -= t - m
		b += t - m
		m = t
		if a < p:
			a = p
		if b > q:
			b = q
		if a > b:
			ans = 'no'
	print(ans)


def readToInt():
	return [int(n) for n in input().split()]

def solve(cus, index, low, high, time):
	if index >= len(cus):
		return True
	(t, l, h) = (cus[index][0], cus[index][1], cus[index][2])
	max_high = high + t - time
	max_low = low - (t - time)
	if max_high < l or h < max_low:
		return False
	return solve(cus, index + 1, max(max_low, l), min(max_high, h), t)
for _ in range(int(input())):
	line = readToInt()
	cus = []
	for _ in range(line[0]):
		cus.append(readToInt())
	if solve(cus, 0, line[1], line[1], 0):
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, tmp) = map(int, input().split())
	MLH = [list(map(int, input().split())) for _ in range(n)]
	tmpl = tmp
	tmph = tmp
	tim = 0
	for (m, l, h) in MLH:
		if h < tmpl - (m - tim) or tmph + (m - tim) < l:
			print('NO')
			break
		else:
			tmpl = max(l, tmpl - (m - tim))
			tmph = min(h, tmph + (m - tim))
			tim = m
	else:
		print('YES')


def intersected(seg1, seg2):
	return (max(seg1[0], seg2[0]), min(seg1[1], seg2[1]))
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	vis = []
	for i in range(n):
		vis.append(tuple(map(int, input().split())))
	vis.sort(reverse=True)
	low = vis[0][1]
	high = vis[0][2]
	cur = (low, high)
	time = vis[0][0]
	ans = 'YES'
	for v in vis[1:]:
		dt = time - v[0]
		next = intersected((cur[0] - dt, cur[1] + dt), (v[1], v[2]))
		if next[0] > next[1]:
			ans = 'NO'
			break
		time = v[0]
		cur = next
	cur = intersected((T - vis[-1][0], T + vis[-1][0]), cur)
	if cur[0] > cur[1]:
		ans = 'NO'
	print(ans)


import math
q = int(input())
for i in range(q):
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	current_temp_low = m
	current_temp_high = m
	c = [[0, 0, 0] for j in range(n)]
	d = {}
	prev_time = 0
	no_intersection = True
	for j in range(n):
		tlh = input().split(' ')
		t = int(tlh[0])
		l = int(tlh[1])
		h = int(tlh[2])
		if t != prev_time:
			current_temp_low = current_temp_low - t + prev_time
			current_temp_high = current_temp_high + t - prev_time
			prev_time = t
		if h < current_temp_low or l > current_temp_high:
			no_intersection = False
		current_temp_low = max(current_temp_low, l)
		current_temp_high = min(current_temp_high, h)
	if no_intersection == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	low = m
	hi = m
	prev = 0
	f = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		low -= t - prev
		hi += t - prev
		if h < low or l > hi:
			f = 1
		low = max(low, l)
		hi = min(hi, h)
		prev = t
		if low > hi:
			f = 1
	if f:
		print('NO')
	else:
		print('YES')


from operator import itemgetter
Q = int(input())
for q in range(Q):
	(n, m) = [int(i) for i in input().split()]
	A = [[int(j) for j in input().split()] for i in range(n)]
	prev = 0
	mn = m
	mx = m
	flag = True
	for i in range(n):
		diff = A[i][0] - prev
		mx += diff
		mn -= diff
		if mx < A[i][1] or mn > A[i][2]:
			flag = False
			break
		mx = min(mx, A[i][2])
		mn = max(mn, A[i][1])
		prev = A[i][0]
	if flag:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	(L, H) = (m, m)
	prev_t = 0
	flag = True
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		L = max(l, L - (t - prev_t))
		H = min(h, H + (t - prev_t))
		if L > H:
			flag = False
		prev_t = t
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, initemp) = map(int, input().split())
	c = []
	for i in range(n):
		c.append(list(map(int, input().split())))
	ans = True
	(lower, upper) = (initemp, initemp)
	time = 0
	for customer in c:
		span = customer[0] - time
		upper = min(upper + span, customer[2])
		lower = max(lower - span, customer[1])
		if upper < lower:
			ans = False
			break
		time = customer[0]
	if ans:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	ls = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		ls.append((t, l, h))
	ls.sort(key=lambda x: x[0])
	nt = 0
	nh = m
	nl = m
	ans = 'YES'
	for p in ls:
		if nh + (p[0] - nt) > p[2]:
			nh = p[2]
		elif nh + (p[0] - nt) >= p[1]:
			nh = nh + (p[0] - nt)
		else:
			ans = 'NO'
			break
		if nl - (p[0] - nt) < p[1]:
			nl = p[1]
		elif nl - (p[0] - nt) <= p[2]:
			nl = nl - (p[0] - nt)
		else:
			ans = 'NO'
			break
		nt = p[0]
	print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]

def makel(l):
	newl = [l[0]]
	for i in range(1, len(l)):
		if l[i][0] != newl[-1][0]:
			newl.append(l[i])
		else:
			newl[-1][1] = max(newl[-1][1], l[i][1])
			newl[-1][2] = min(newl[-1][2], l[i][2])
	return newl
for _ in range(val()):
	(n, m) = li()
	currtime = currfree = 0
	l = []
	for i in range(n):
		l.append(li())
	l = makel(l)
	n = len(l)
	for i in range(len(l)):
		if l[i][1] > l[i][2]:
			ans = 'NO'
			break
	l.sort(key=lambda x: x[0])
	ans = 'YES'
	curr = [0, 0]
	curr[0] = max(m - l[0][0], l[0][1])
	curr[1] = min(m + l[0][0], l[0][2])
	if curr[0] > curr[1]:
		ans = 'NO'
	for i in range(1, n):
		curr[0] = max(curr[0] - (l[i][0] - l[i - 1][0]), l[i][1])
		curr[1] = min(curr[1] + (l[i][0] - l[i - 1][0]), l[i][2])
		if curr[0] > curr[1]:
			ans = 'NO'
			break
	print(ans)


q = int(input())
for _ in range(q):
	l = list(map(int, input().split()))
	(n, m) = (l[0], l[1])
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split())))
	if arr[0][1] > m + arr[0][0] or arr[0][2] < m - arr[0][0]:
		print('NO')
		continue
	else:
		arr[0][1] = max(arr[0][1], m - arr[0][0])
		arr[0][2] = min(arr[0][2], m + arr[0][0])
		key = 0
		for i in range(1, n):
			if arr[i][1] > arr[i - 1][2] + (arr[i][0] - arr[i - 1][0]) or arr[i][2] < arr[i - 1][1] - (arr[i][0] - arr[i - 1][0]):
				key = 1
				break
			else:
				arr[i][1] = max(arr[i][1], arr[i - 1][1] - (arr[i][0] - arr[i - 1][0]))
				arr[i][2] = min(arr[i][2], arr[i - 1][2] + (arr[i][0] - arr[i - 1][0]))
		if key == 0:
			print('YES')
		else:
			print('NO')


has_tests = True

def solve_case():
	(n, temp) = get([int])
	time = 0
	possible_low = temp
	possible_high = temp
	for (t, low, high) in get([int], n):
		delta = t - time
		possible_low = possible_low - delta
		possible_high = possible_high + delta
		possible_low = max(low, possible_low)
		possible_high = min(high, possible_high)
		if possible_low > possible_high:
			return 'NO'
		time = t
	return 'YES'

def get(x, times=None):
	if times is not None:
		return [get(x, times=None) for _ in range(times)]
	if isinstance(x, list):
		return list(map(x[0], input().strip().split()))
	return x(input().strip())
if has_tests:
	for _ in range(get(int)):
		print(solve_case())
else:
	solve_case()


def faltu(a, b):
	ans = []
	zero = max(a[0], b[0])
	one = min(a[1], b[1])
	if zero > one:
		ans.append(1.5)
		ans.append(1.5)
	else:
		ans.append(zero)
		ans.append(one)
	return ans
t = int(input())
for p in range(0, t):
	flag = 0
	(n, m) = map(int, input().split())
	tym = 0
	temp1 = m
	temp2 = m
	for i in range(0, n):
		(t, l, h) = map(int, input().split())
		tymdiff = t - tym
		temp1 = temp1 - tymdiff
		temp2 = temp2 + tymdiff
		temp1 = max(l, temp1)
		temp2 = min(h, temp2)
		tym = t
		if temp1 > temp2 and flag == 0:
			flag = 1
			print('NO')
	if flag == 0:
		print('YES')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	m1 = t
	m2 = t
	time = 0
	f = 0
	for i in range(n):
		(t, lo, hi) = map(int, input().split())
		m1 = m1 - (t - time)
		m2 = m2 + (t - time)
		if m2 < lo or m1 > hi:
			f = 1
		else:
			time = t
			m1 = max(m1, lo)
			m2 = min(m2, hi)
	if f:
		print('NO')
	else:
		print('YES')


def f():
	(m, t0) = map(int, input().split())
	time = 0
	(upp, loww) = (t0, t0)
	for j in range(m):
		(t, l, h) = map(int, input().split())
		loww = max(loww - (t - time), l)
		upp = min(upp + (t - time), h)
		if upp < loww:
			for musor in range(j + 1, m):
				musor = input()
			return False
		time = t
	return True
n = int(input())
for i in range(n):
	print('YES' if f() else 'NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	mini = m
	maxi = m
	ctime = 0
	can = True
	for __ in range(n):
		(t, l, h) = map(int, input().split())
		mini = max(mini - (t - ctime), l)
		maxi = min(maxi + (t - ctime), h)
		if maxi >= l and mini <= h:
			ctime = t
			continue
		else:
			can = False
	if can:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(0, t):
	(n, m) = map(int, input().split(' '))
	tr = []
	li = []
	hi = []
	for __ in range(0, n):
		(a, b, c) = map(int, input().split(' '))
		tr.append(a)
		li.append(b)
		hi.append(c)
	(mn, mx) = (m, m)
	prev = 0
	ans = True
	for i in range(0, n):
		mx += tr[i] - prev
		mn -= tr[i] - prev
		if mx < li[i] or mn > hi[i]:
			ans = False
			break
		mx = min(mx, hi[i])
		mn = max(mn, li[i])
		prev = tr[i]
	if ans:
		print('YES')
	else:
		print('NO')


import sys
inp = sys.stdin.readline
input = lambda : inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	T = iin()
	while T:
		T -= 1
		(n, m) = lin()
		a = [lin() for i in range(n)]
		done = 0
		(ml, mh) = (m, m)
		pt = 0
		for (t, l, h) in a:
			t1 = t - pt
			ml -= t1
			mh += t1
			if l <= ml <= h and l <= mh <= h:
				pass
			elif l <= ml <= h:
				mh = h
			elif l <= mh <= h:
				ml = l
			elif ml <= l and h <= mh:
				ml = l
				mh = h
			else:
				done = 1
				break
			pt = t
		if done:
			print('NO')
		else:
			print('YES')
main()


R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, m) = R()
	t0 = 0
	(pl, ph) = (m, m)
	isGood = True
	for i in range(n):
		(t, l, h) = R()
		(pl, ph) = (max(pl - (t - t0), l), min(ph + t - t0, h))
		t0 = t
		if pl > ph:
			isGood = False
	print('YES' if isGood else 'NO')


q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	F = []
	for k in range(n):
		(t, a, b) = map(int, input().split())
		F.append([t, a, b])
	f0 = [0, m, m]
	gmax0 = m
	gmin0 = m
	fl = True
	for j in range(n):
		f1 = F[j]
		dt = f1[0] - f0[0]
		gmax1 = gmax0 + dt
		gmin1 = gmin0 - dt
		if gmax1 < f1[1] or gmin1 > f1[2]:
			fl = False
			break
		else:
			if gmax1 < f1[2]:
				gmax0 = gmax1
			else:
				gmax0 = f1[2]
			if gmin1 > f1[1]:
				gmin0 = gmin1
			else:
				gmin0 = f1[1]
		f0 = f1
	if fl:
		print('yes')
	else:
		print('no')


def main():
	import sys
	input = sys.stdin.readline
	Q = int(input())
	for _ in range(Q):
		(n, m) = map(int, input().split())
		(time, lo, hi) = (0, m, m)
		poss = True
		for i in range(n):
			(t, l, r) = map(int, input().split())
			d = t - time
			lo -= d
			hi += d
			hi = min(hi, r)
			lo = max(lo, l)
			if lo > hi:
				poss = False
			time = t
		print('yes' if poss else 'no')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mini = maxi = m
	flag = 0
	prev = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		mini -= t - prev
		maxi += t - prev
		mini = max(mini, l)
		maxi = min(maxi, h)
		if mini > maxi:
			flag = 1
		prev = t
	print('YES' if flag == 0 else 'NO')


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		(x_hi, x_lo, tt, fl) = (m, m, 0, 0)
		for _ in range(n):
			(t, l, h) = map(int, input().split())
			(y, z) = (x_hi + t - tt, x_lo + tt - t)
			if y < l or z > h:
				fl = 1
			(x_lo, x_hi, tt) = (max(l, z), min(h, y), t)
		if fl:
			print('NO')
		else:
			print('YES')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for ti in range(t):
	(cus, ini) = (int(i) for i in input().split(' '))
	infos = []
	for i in range(cus):
		infos.append(list((int(i) for i in input().split(' '))))
	infos.sort(key=lambda x: x[0])
	ind = 1
	while ind < len(infos):
		if infos[ind][0] == infos[ind - 1][0]:
			infos[ind - 1][1] = max(infos[ind - 1][1], infos[ind][1])
			infos[ind - 1][2] = min(infos[ind - 1][2], infos[ind][2])
			infos.pop(ind)
		else:
			ind += 1
	infos.sort()
	dn = 1
	for (ind, (t, d, h)) in enumerate(infos):
		if d > h:
			dn = 0
			break
		if ind == 0:
			if ini > h:
				if ini - h <= t:
					cdd = max(ini - t, d)
					cdh = h
				else:
					dn = 0
					break
			elif ini < d:
				if d - ini <= t:
					cdd = d
					cdh = min(h, t + ini)
				else:
					dn = 0
					break
			else:
				cdd = max(d, ini - t)
				cdh = min(h, ini + t)
		else:
			se = t - infos[ind - 1][0]
			if cdd > h:
				if cdd - h <= se:
					cdd = max(d, cdd - se)
					cdh = h
				else:
					dn = 0
					break
			elif cdh < d:
				if d - cdh <= se:
					cdd = d
					cdh = min(h, se + cdh)
				else:
					dn = 0
					break
			else:
				cdd = max(d, cdd - se)
				cdh = min(h, cdh + se)
		if cdd > cdh:
			dn = 0
			break
	if dn:
		print('YES')
	else:
		print('NO')


q = int(input())
for rewrew in range(q):
	(n, t0) = map(int, input().split())
	t = []
	l = []
	h = []
	for i in range(n):
		(tt, ll, hh) = map(int, input().split())
		t.append(tt)
		l.append(ll)
		h.append(hh)
	possib = [[0, 0]] * n
	dasie = True
	possib[0] = [-t[0] + t0, t[0] + t0]
	for i in range(n):
		if l[i] > possib[i][1] or h[i] < possib[i][0]:
			dasie = False
			break
		else:
			possib[i][0] = max(possib[i][0], l[i])
			possib[i][1] = min(possib[i][1], h[i])
		if i < n - 1:
			possib[i + 1][0] = possib[i][0] - (t[i + 1] - t[i])
			possib[i + 1][1] = possib[i][1] + (t[i + 1] - t[i])
	if dasie:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def main():
	q = inp()
	for i in range(0, q):
		[n, m] = inlt()
		limit_L = m
		limit_h = m
		curr_time = 0
		flag = 1
		for j in range(0, n):
			[t, l, h] = inlt()
			limit_L = limit_L - (t - curr_time)
			limit_h = limit_h + (t - curr_time)
			if limit_L > h or limit_h < l:
				flag = 0
			curr_time = t
			limit_L = max(limit_L, l)
			limit_h = min(limit_h, h)
		if flag == 1:
			print('YES')
		else:
			print('NO')
	return
main()


import sys

def reverse(s):
	return s[::-1]

def main():
	N = int(sys.stdin.readline().strip())
	for _ in range(N):
		(n, m) = [int(s) for s in sys.stdin.readline().strip().split()]
		a = []
		for i in range(n):
			(t, l, h) = [int(s) for s in sys.stdin.readline().strip().split()]
			a.append((t, l, h))
		tt = 0
		ll = m
		hh = m
		for (t, l, h) in a:
			dt = t - tt
			maxh = hh + dt
			minl = ll - dt
			if maxh < l or minl > h:
				print('NO')
				break
			ll = max(l, minl)
			hh = min(h, maxh)
			tt = t
			if ll > hh:
				print('NO')
				break
		else:
			print('YES')
main()


def find_ans(n, temp):
	times = [0]
	lower = [temp]
	upper = [temp]
	k = False
	for i in range(n):
		(t, l, r) = map(int, input().split())
		if times[-1] == t:
			lower[-1] = max(lower[-1], l)
			upper[-1] = min(upper[-1], r)
			if lower[-1] > upper[-1]:
				k = True
		else:
			times.append(t)
			lower.append(l)
			upper.append(r)
	if k:
		return 0
	time = 0
	lower_bound = temp
	upper_bound = temp
	for i in range(1, len(times)):
		upper_bound += times[i] - time
		lower_bound -= times[i] - time
		time = times[i]
		if lower_bound > upper[i] or upper_bound < lower[i]:
			return False
		upper_bound = min(upper[i], upper_bound)
		lower_bound = max(lower[i], lower_bound)
	return True
for _ in range(int(input())):
	(n, temp) = map(int, input().split())
	print('YES') if find_ans(n, temp) else print('NO')


for _ in range(int(input())):
	(n, ti) = map(int, input().split())
	ans = 'YES'
	p = []
	for i in range(n):
		p.append(list(map(int, input().split())))
	p.sort()
	low = ti
	high = ti
	itime = 0
	for i in range(n):
		t = p[i][0]
		l = p[i][1]
		h = p[i][2]
		timediff = t - itime
		itime = t
		low -= timediff
		high += timediff
		low = max(low, l)
		high = min(h, high)
		if low > high:
			ans = 'NO'
	print(ans)


def solve():
	(N, M) = map(int, input().split())
	L = [list(map(int, input().split())) for _ in range(N)]
	current_time = 0
	lower = M
	higher = M
	for (t, l, h) in L:
		margin_time = t - current_time
		lowerst = lower - margin_time
		highest = higher + margin_time
		if l <= lowerst <= highest <= h:
			lower = lowerst
			higher = highest
		elif lowerst <= l <= h <= highest:
			lower = l
			higher = h
		elif l <= lowerst <= h:
			lower = lowerst
			higher = h
		elif l <= highest <= h:
			lower = l
			higher = highest
		else:
			print('NO')
			return
		current_time = t
	print('YES')
T = int(input())
for _ in range(T):
	solve()


n = int(input())
for i in range(0, n):
	list = input()
	(a, b) = list.split()
	intem = int(b)
	ltemp = intem
	ctim = 0
	fall = 0
	htemp = intem
	nocust = int(a)
	for j in range(0, nocust):
		clis = input()
		(tim, cltemp, chtemp) = clis.split()
		diff = int(tim) - ctim
		ctim = int(tim)
		possltemp = ltemp - diff
		posshtemp = htemp + diff
		ltemp = int(cltemp) if int(cltemp) > possltemp else possltemp
		htemp = int(chtemp) if int(chtemp) < posshtemp else posshtemp
		if ltemp > htemp:
			fall = 1
	if fall == 1:
		print('NO')
	else:
		print('YES')


from sys import stdout

def intersected(seg1, seg2):
	if seg1[0] > seg2[0]:
		(seg1, seg2) = (seg2, seg1)
	if seg1[1] < seg2[0]:
		return (-1, -1)
	return (seg2[0], min(seg1[1], seg2[1]))
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	vis = []
	for i in range(n):
		vis.append(tuple(map(int, input().split())))
	vis.sort(reverse=True)
	low = vis[0][1]
	high = vis[0][2]
	time = vis[0][0]
	ans = 'YES'
	for v in vis[1:]:
		dt = time - v[0]
		low = max(v[1], low - dt)
		high = min(v[2], high + dt)
		if low > high:
			ans = 'NO'
			break
		time = v[0]
	if low > T + time or high < T - time:
		ans = 'NO'
	print(ans)


testCases = int(input())
for i1 in range(testCases):
	(n, m) = list(map(int, input().split()))
	curr = [m, m]
	time = 0
	result = 'YES'
	for i2 in range(n):
		(t, l, h) = list(map(int, input().split()))
		x = t - time
		time = t
		curr[0] -= x
		curr[1] += x
		curr[0] = max(curr[0], l)
		curr[1] = min(curr[1], h)
		if curr[0] > curr[1]:
			result = 'NO'
	print(result)


case = int(input())
for i in range(case):
	count = 0
	(m, a) = (int(v) for v in input().split())
	b = a
	s = 0
	for j in range(m):
		(t, c, d) = (int(u) for u in input().split())
		a = a - (t - s)
		b = b + (t - s)
		if b < c or d < a:
			print('NO')
			for k in range(m - j - 1):
				(t, c, d) = (int(u) for u in input().split())
			break
		else:
			count += 1
			a = max(a, c)
			b = min(b, d)
			s = t
	if count == m:
		print('YES')


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	ans = 'YES'
	(n, m) = map(int, input().split())
	tlh = [list(map(int, input().split())) for __ in range(n)]
	t_ = 0
	l_ = m
	h_ = m
	for i in range(n):
		(t, l, h) = tlh[i]
		l_ -= t - t_
		h_ += t - t_
		if l_ > h:
			ans = 'NO'
			break
		elif h_ < l:
			ans = 'NO'
			break
		else:
			t_ = t
			l_ = max(l_, l)
			h_ = min(h_, h)
	print(ans)


def getIntersect(a, b, c, d):
	return (max(a, c), min(b, d))

def solve(N, M, A):
	tHi = M
	tLo = M
	A.sort()
	lastT = 0
	for (t, l, h) in A:
		deltaT = t - lastT
		tLo -= deltaT
		tHi += deltaT
		(tLo, tHi) = getIntersect(tLo, tHi, l, h)
		if tLo > tHi:
			return 'NO'
		lastT = t
	return 'YES'

def __starting_point():
	(T,) = list(map(int, input().split()))
	for t in range(T):
		(N, M) = list(map(int, input().split()))
		A = []
		for i in range(N):
			tlh = [int(x) for x in input().split()]
			A.append(tlh)
		ans = solve(N, M, A)
		print(ans)
__starting_point()


Q = int(input())
for _ in range(Q):
	(n, m) = map(int, input().split())
	(lt, mn, mx) = (0, m, m)
	ok = True
	for i in range(n):
		if ok:
			(t, l, h) = map(int, input().split())
			mn = max(mn - (t - lt), l)
			mx = min(mx + (t - lt), h)
			lt = t
			if mn > mx:
				ok = False
		else:
			input()
	print('YES' if ok else 'NO')


ip = lambda : map(int, input().split())
t = int(input())
for ti in range(t):
	(n, s) = ip()
	mn = mx = s
	pt = 0
	cus = [tuple(ip()) for x in range(n)]
	cus.sort()
	p = True
	for (k, l, h) in cus:
		k = k - pt
		mn = mn - k
		mx = mx + k
		if mn > h or mx < l:
			p = False
			break
		pt += k
		(mn, mx) = (max(l, mn), min(h, mx))
	print('YES' if p else 'NO')


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' ', **kwargs):
	print(space.join(map(str, lista)), **kwargs)

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path

def intersect(a, b):
	m = max(a[0], b[0])
	M = min(a[1], b[1])
	return [m, M]

def f(a):
	te = [m, m]
	curr_t = 0
	for i in range(n):
		(t, l, h) = a[i]
		te[0] -= t - curr_t
		te[1] += t - curr_t
		te = intersect(te, [l, h])
		curr_t = t
		if te[0] > te[1]:
			return False
	return True
for test in range(ii()):
	(n, m) = li()
	a = list()
	for i in range(n):
		b = li()
		a.append(b)
	a.sort()
	if f(a):
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = list(map(int, input().split()))
	temp = []
	for i in range(n):
		temp.append(list(map(int, input().split())))
	f = 0
	(l, r, t) = (m, m, 0)
	for i in range(n):
		d = temp[i][0] - t
		l = l - d
		r = r + d
		if l <= temp[i][1] and r >= temp[i][2]:
			l = temp[i][1]
			r = temp[i][2]
		elif l <= temp[i][1] and r <= temp[i][2] and (r >= temp[i][1]):
			l = temp[i][1]
		elif l >= temp[i][1] and r >= temp[i][2] and (l <= temp[i][2]):
			r = temp[i][2]
		elif l >= temp[i][1] and r <= temp[i][2]:
			(l, r) = (l, r)
		else:
			f = 1
			break
		t = temp[i][0]
	if f:
		print('NO')
	else:
		print('YES')


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, m) = [int(x) for x in input().split()]
		x = 0
		(next_h, next_l) = [m, m]
		series = []
		for i in range(n):
			series.append([int(x) for x in input().split()])
		not_possible = False
		for p in series:
			(t, l, h) = p
			d = t - x
			x = t
			next_h += d
			next_l -= d
			if next_l <= l <= next_h or next_l <= h <= next_h or (h > next_h and l < next_l):
				next_h = min(next_h, h)
				next_l = max(next_l, l)
			else:
				not_possible = True
				break
		if not_possible:
			print('NO')
		else:
			print('YES')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


func = lambda i: [min(i), max(i)] if i != set() else []
for i in range(int(input())):
	(n, t0) = map(int, input().split())
	t0 = [t0]
	tnow = 0
	flag = True
	for i in range(n):
		(time, low, high) = map(int, input().split())
		if not flag:
			continue
		delta_t = time - tnow
		if max(t0) + delta_t + 1 <= low or high + 1 <= min(t0) - delta_t:
			flag = False
			continue
		set_temp = [max(min(t0) - delta_t, low), min(high, max(t0) + delta_t)]
		if len(set_temp) == 0:
			print('NO')
			flag = False
			continue
		else:
			t0 = set_temp[:]
			tnow = time
	if flag:
		print('YES')
	else:
		print('NO')


from math import *
te = int(input())
for y in range(te):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		a.append(list(map(int, input().split())))
	a.sort()
	l = []
	f = 0
	L = m - a[0][0]
	R = m + a[0][0]
	for i in range(n):
		if a[i][2] < L or a[i][1] > R:
			f = 1
		else:
			R = min(R, a[i][2])
			L = max(L, a[i][1])
		if i != n - 1:
			L = L - a[i + 1][0] + a[i][0]
			R = R + a[i + 1][0] - a[i][0]
	if f == 0:
		print('YES')
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		a = [LI() for _ in range(n)]
		ok = 1
		c = [0, m, m]
		for (t, l, h) in a:
			b = t - c[0]
			nl = max(l, c[1] - b)
			nh = min(h, c[2] + b)
			if nl > nh:
				ok = 0
				break
			c = [t, nl, nh]
		rr.append(YES(ok))
	return JA(rr, '\n')
print(main())


import sys
input = sys.stdin.readline
Q = int(input())
for q in range(Q):
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	line = []
	for i in range(n):
		(t, l, h) = input().split()
		(t, l, h) = (int(t), int(l), int(h))
		line.append([t, l, h])
	line = sorted(line)
	(lb, ub) = (m - line[0][0], m + line[0][0])
	(lb, ub) = (max(lb, line[0][1]), min(ub, line[0][2]))
	if lb > ub:
		print('NO')
		continue
	for i in range(1, n):
		d = line[i][0] - line[i - 1][0]
		(l, h) = (line[i][1], line[i][2])
		(lb, ub) = (max(l, lb - d), min(h, ub + d))
		if lb > ub:
			break
	if lb > ub:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	(t1, l1, h1) = (0, m, m)
	ans = 'YES'
	for j in range(n):
		(t, l, h) = map(int, input().split())
		if l > h1 + (t - t1) or h < l1 - (t - t1):
			ans = 'NO'
		h1 = min(h, h1 + (t - t1))
		l1 = max(l, l1 - (t - t1))
		t1 = t
	print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, initemp) = map(int, input().split())
		res = True
		temprange = [initemp, initemp]
		prevtime = 0
		for _ in range(n):
			if res:
				(time, lower, upper) = map(int, input().split())
				(prevlow, prevup) = temprange
				(nowlow, nowup) = (prevlow - (time - prevtime), prevup + (time - prevtime))
				if nowlow < lower:
					fixlow = lower
					if nowup < lower:
						fixup = nowup
						res = False
					elif nowup > upper:
						fixup = upper
					else:
						fixup = nowup
				elif nowlow > upper:
					(fixlow, fixup) = (nowlow, nowup)
					res = False
				else:
					fixlow = nowlow
					if nowup > upper:
						fixup = upper
					else:
						fixup = nowup
				temprange = [fixlow, fixup]
				prevtime = time
			else:
				kappa = input()
		if res:
			yield 'YES'
		else:
			yield 'NO'
t = int(input())
ans = gift()
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li = []
	for i in range(n):
		r = list(map(int, input().split()))
		li.append(r)
	minm = m
	maxm = m
	flag = 0
	last = 0
	for i in range(n):
		l = li[i][1]
		r = li[i][2]
		t = li[i][0]
		(last, t) = (t, t - last)
		if r >= minm - t and l <= maxm + t:
			minm = max(l, minm - t)
			maxm = min(maxm + t, r)
		else:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


def solve():
	(n, m) = map(int, input().split())
	cust = []
	for ___ in range(n):
		(t, l, h) = map(int, input().split())
		cust.append((t, l, h))
	cust.sort()
	lastT = 0
	lastMaxT = m
	lastMinT = m
	for (t, l, h) in cust:
		nextMax = lastMaxT + t - lastT
		nextMin = lastMinT - t + lastT
		if nextMax < l or nextMin > h:
			print('NO')
			return
		lastMaxT = min(h, nextMax)
		lastMinT = max(l, nextMin)
		lastT = t
	print('YES')
q = int(input())
for __ in range(q):
	solve()


import sys
testCastCount = int(input())

def answer(customerList, initialTemperature):
	currentT = 0
	currentMin = initialTemperature
	currentMax = initialTemperature
	for i in range(len(customerList)):
		(t, preferredMin, preferredMax) = customerList[i]
		x = t - currentT
		currentT = t
		possibleMax = currentMax + x
		possibleMin = currentMin - x
		if possibleMax < preferredMin or possibleMin > preferredMax:
			return 'NO'
		currentMax = preferredMax
		currentMin = preferredMin
		if possibleMax <= preferredMax:
			currentMax = possibleMax
		if possibleMin >= preferredMin:
			currentMin = possibleMin
	return 'YES'
for _ in range(testCastCount):
	(reservedCustomers, initialTemperature) = list(map(int, input().split()))
	customerList = []
	for __ in range(reservedCustomers):
		customerList.append(list(map(int, input().split())))
	print(answer(customerList, initialTemperature))


t = int(input())
a = []
for i in range(t):
	(m, n) = map(int, input().split())
	k = []
	for j in range(m):
		b = list(map(int, input().split()))
		k.append(b)
	k.append([n])
	a.append(k)
for i in a:
	n = i[-1][0]
	i.remove(i[-1])
	min = n
	max = n
	x = 0
	s = 0
	for j in range(len(i)):
		if j > 0:
			t = abs(i[j][0] - i[j - 1][0])
		else:
			t = i[0][0]
		l = i[j][1]
		u = i[j][2]
		min = min - t
		max = max + t
		if max < l:
			x = 1
		elif max >= l and max <= u:
			if min < l:
				min = l
			else:
				min = min
		elif max > u:
			if min < l:
				min = l
				max = u
			elif min >= l and min <= u:
				min = min
				max = u
			else:
				x = 1
		if x == 1:
			print('NO')
			s = 1
			break
	if s == 0:
		print('YES')


cases_ = int(input())

def intersect_(l_1, u_1, l_2, u_2):
	if l_1 <= l_2 and l_2 <= u_1:
		l_int = l_2
		u_int = min(u_1, u_2)
		return sorted(list(set([l_int, u_int])))
	elif l_2 <= l_1 and l_1 <= u_2:
		l_int = l_1
		u_int = min(u_1, u_2)
		return sorted(list(set([l_int, u_int])))
	else:
		return []

def air_cond(temp_input, list_, n):
	(first_time, first_l, first_h) = (list_[0][0], list_[0][1], list_[0][2])
	intersect = intersect_(first_l, first_h, temp_input - first_time, temp_input + first_time)
	if len(intersect) == 0:
		return 0
	else:
		if n == 1:
			return 1
		for i in range(1, n):
			(new_time, new_l, new_h) = (list_[i][0], list_[i][1], list_[i][2])
			if len(intersect) > 1:
				reachable_set = [intersect[0] - new_time + first_time, intersect[1] + new_time - first_time]
			else:
				reachable_set = [intersect[0] - new_time + first_time, intersect[0] + new_time - first_time]
			intersect = intersect_(new_l, new_h, reachable_set[0], reachable_set[1])
			if len(intersect) == 0:
				return 0
			first_time = new_time
		return 1
for i in range(cases_):
	list_ = list()
	(n_cust, temp_) = list(map(int, input().split()))
	for j in range(n_cust):
		temp_input = list(map(int, input().split()))
		list_.append(temp_input)
	if air_cond(temp_, list_, n_cust) == 0:
		print('NO')
	else:
		print('YES')


Q = int(input())

def temperature_distance(guest, temperature):
	if guest[1] <= temperature <= guest[2]:
		return (0, temperature)
	elif abs(temperature - guest[1]) > abs(temperature - guest[2]):
		return (abs(temperature - guest[2]), guest[2])
	else:
		return (abs(temperature - guest[1]), guest[1])
for i in range(Q):
	line = input().split(' ')
	N = int(line[0])
	temperature = int(line[1])
	success = True
	guests = []
	for j in range(N):
		line = input().split(' ')
		guests.append((int(line[0]), int(line[1]), int(line[2])))
	possible_range = (temperature, temperature)
	last_time = 0
	for guest in guests:
		time_to_change = guest[0] - last_time
		possible_range = (possible_range[0] - time_to_change, possible_range[1] + time_to_change)
		if guest[1] > possible_range[1] or guest[2] < possible_range[0]:
			success = False
			break
		else:
			possible_range = (max(possible_range[0], guest[1]), min(possible_range[1], guest[2]))
			last_time = guest[0]
	if success:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	(N, M) = map(int, input().split())
	TLR = [list(map(int, input().split())) for _ in range(N)]
	Query.append((N, M, TLR))
for (N, M, TLR) in Query:
	TLR.sort()
	large = M
	small = M
	pret = 0
	ok = True
	for (t, l, r) in TLR:
		delta = t - pret
		large += delta
		small -= delta
		if large < l or r < small:
			ok = False
			break
		large = min(large, r)
		small = max(small, l)
		pret = t
	print('YES' if ok else 'NO')


q = int(input())
for test_case in range(q):
	(n, temp) = map(int, input().split())
	satisfiable = True
	time_prev = 0
	max_temp = min_temp = temp
	for customer in range(n):
		t_l_h = input()
		if satisfiable:
			(t, l, h) = map(int, t_l_h.split())
			max_temp += t - time_prev
			min_temp -= t - time_prev
			time_prev = t
			if h < min_temp or l > max_temp:
				satisfiable = False
			max_temp = min(h, max_temp)
			min_temp = max(l, min_temp)
	if not satisfiable:
		print('NO\n')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	arr = []
	for i in range(n):
		arr.append([int(i) for i in input().split()])
	prev = flag = 0
	m_l = m_h = m
	for i in range(len(arr)):
		(t1, l1, h1) = arr[i]
		k = t1 - prev
		m_l -= k
		m_h += k
		if m_h < l1 or m_l > h1:
			flag = 1
			break
		m_l = max(m_l, l1)
		m_h = min(m_h, h1)
		prev = t1
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.buffer.readline

def prog():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		customers = [list(map(int, input().split()))]
		failed = False
		for i in range(n - 1):
			(t, l, r) = map(int, input().split())
			if customers[-1][0] == t:
				if not (customers[-1][2] < l or r < customers[-1][1]):
					customers[-1][1] = max(customers[-1][1], l)
					customers[-1][2] = min(customers[-1][2], r)
				else:
					failed = True
			else:
				customers.append([t, l, r])
		if failed:
			print('NO')
			continue
		r = m
		l = m
		time = 0
		for customer in customers:
			time_diff = customer[0] - time
			r += time_diff
			l -= time_diff
			if not (customer[2] < l or r < customer[1]):
				r = min(r, customer[2])
				l = max(l, customer[1])
				time = customer[0]
			else:
				failed = True
				break
		if failed:
			print('NO')
		else:
			print('YES')
prog()


for q in range(int(input())):
	(n, m) = map(int, input().split())
	low = m
	high = m
	flag = True
	t1 = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		t1 = t - t1
		a = low - t1
		b = high + t1
		if flag == True:
			if b >= l and a <= h:
				flag = True
			else:
				flag = False
			low = max(a, l)
			high = min(b, h)
			t1 = t
	if flag == False:
		print('NO')
	else:
		print('YES')


import math
import collections
import sys

def inpu():
	return input().split(' ')

def inti(a):
	for i in range(len(a)):
		a[i] = int(a[i])
	return a

def inp():
	a = inpu()
	a = inti(a)
	return a

def solution():
	(n, m) = map(int, input().split())
	li = []
	for i in range(n):
		r = list(map(int, input().split()))
		li.append(r)
	minm = m
	maxm = m
	flag = 0
	last = 0
	for i in range(n):
		l = li[i][1]
		r = li[i][2]
		t = li[i][0]
		(last, t) = (t, t - last)
		if r >= minm - t and l <= maxm + t:
			minm = max(l, minm - t)
			maxm = min(maxm + t, r)
		else:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')
for _ in range(int(input())):
	solution()


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
t = ii()
for _ in range(t):
	(n, m) = mi()
	p = []
	for i in range(n):
		p.append(li())
	min_ = max_ = m
	dt = 0
	for item in p:
		max_ += item[0] - dt
		min_ -= item[0] - dt
		if min_ > item[2] or item[1] > max_:
			print('NO')
			break
		min_ = max(min_, item[1])
		max_ = min(max_, item[2])
		dt = item[0]
	else:
		print('YES')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections

def getOverlap(a, b):
	return max(0, min(a[1], b[1]) - max(a[0], b[0]) + 1)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	temp = {}
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if t not in temp:
			temp[t] = [[l, h]]
		else:
			temp[t] += [[l, h]]
	od = collections.OrderedDict(sorted(temp.items()))
	possible = None
	curt = m
	pos = True
	for (t, intervals) in od.items():
		if not pos:
			break
		if not possible:
			possible = [m - t, m + t]
			curt = t
			for i in range(len(intervals)):
				if getOverlap(intervals[i], possible) == 0:
					pos = False
					break
				else:
					possible = [max(intervals[i][0], possible[0]), min(intervals[i][1], possible[1])]
		else:
			diff = t - curt
			curt = t
			possible = [possible[0] - diff, possible[1] + diff]
			for i in range(len(intervals)):
				if getOverlap(intervals[i], possible) == 0:
					pos = False
					break
				else:
					possible = [max(intervals[i][0], possible[0]), min(intervals[i][1], possible[1])]
	print('YES' if pos else 'NO')


import sys, itertools, math
T = int(sys.stdin.readline())
for _ in range(T):
	(n, m) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	ans = True
	G = {}
	for _ in range(n):
		(t, l, h) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
		if t in G:
			(gl, gh) = G[t]
			if h < gl or l > gh:
				ans = False
			else:
				G[t] = (max(l, gl), min(h, gh))
		else:
			G[t] = (l, h)
	G = sorted(G.items())
	min_t = m
	max_t = m
	last_t = 0
	for (t, (l, h)) in G:
		min_t -= t - last_t
		max_t += t - last_t
		if h < min_t or l > max_t:
			ans = False
			break
		min_t = max(l, min_t)
		max_t = min(h, max_t)
		last_t = t
	if ans:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	s = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		s.append([t, l, h])
	s2 = s
	last_t = 0
	last_min = m
	last_max = m
	f = True
	for shag in range(len(s2)):
		dt = s2[shag][0] - last_t
		tmax = last_max + dt
		tmin = last_min - dt
		if tmin <= s2[shag][2] and tmax >= s2[shag][1]:
			tmax = min(tmax, s[shag][2])
			tmin = max(tmin, s[shag][1])
		else:
			f = False
			break
		last_min = tmin
		last_max = tmax
		last_t = s2[shag][0]
	if f:
		print('YES')
	else:
		print('NO')


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def s_to_int(a):
	for i in range(len(a)):
		a[i] = int(a[i])

def factors(n):
	res = []
	t = 1
	while t * t <= n:
		if t * t == n:
			res.append(t)
		if n % t == 0:
			res.append(t)
			res.append(n // t)
		t += 1
	res.sort()
	return res

def compact_factors(n):
	res = []
	t = 2
	while t * t <= n:
		cnt = 0
		while n % t == 0:
			cnt += 1
			n //= t
		if cnt != 0:
			res.append([t, cnt])
		t += 1
	return res

def binary_search(l, target, lp, rp):
	mid = (lp + rp) // 2
	if l[mid] == target:
		return mid
	elif l[mid] > target:
		binary_search(l, target, lp, mid - 1)
	elif l[mid] < target:
		binary_search(l, target, mid + 1, rp)
	elif lp >= rp:
		return -1
n = inp()
for i in range(n):
	l = inlt()
	m = l[0]
	t = l[1]
	lowest = t
	highest = t
	previous_time = 0
	flag = 1
	for j in range(m):
		l = inlt()
		time = l[0]
		lower = l[1]
		higher = l[2]
		max_increase = time - previous_time
		if highest + max_increase >= higher:
			highest = higher
		elif highest + max_increase >= lower:
			highest = highest + max_increase
		else:
			flag = 0
		if lowest - max_increase <= lower:
			lowest = lower
		elif lowest - max_increase <= higher:
			lowest = lowest - max_increase
		else:
			flag = 0
		previous_time = time
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, a) = (int(x) for x in input().strip().split(' '))
	(t, l, r) = (0, a, a)
	L = []
	for _z in range(n):
		L.append([int(x) for x in input().strip().split(' ')])
	ans = True
	for x in L:
		d = x[0] - t
		l1 = l - d
		r1 = r + d
		if x[2] < l1 or x[1] > r1:
			ans = False
			break
		l = max(x[1], l1)
		r = min(x[2], r1)
		t = x[0]
	if ans:
		print('YES')
	else:
		print('NO')


import sys
from collections import defaultdict
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for _ in range(n)]
	temp = defaultdict(lambda : [-10 ** 9, 10 ** 9])
	for (ti, li, hi) in a:
		temp[ti][0] = max(temp[ti][0], li)
		temp[ti][1] = min(temp[ti][1], hi)
	ct = 0
	(lb, ub) = (m, m)
	for k in sorted(temp.keys()):
		ub += k - ct
		lb -= k - ct
		ct = k
		if temp[k][0] > temp[k][1] or not (lb <= temp[k][1] and temp[k][0] <= ub):
			print('NO')
			break
		lb = max(lb, temp[k][0])
		ub = min(ub, temp[k][1])
	else:
		print('YES')


q = int(input())
while q > 0:
	time = 0
	(n, t) = map(int, input().split())
	arr = []
	for i in range(n):
		a = list(map(int, input().split()))
		arr.append(a)
	lt = t
	ht = t
	flag = 1
	for i in range(n):
		r = arr[i][0] - time
		lt -= r
		ht += r
		if arr[i][1] > ht or arr[i][2] < lt:
			flag = 0
			break
		lt = max(lt, arr[i][1])
		ht = min(ht, arr[i][2])
		time = arr[i][0]
	if flag == 0:
		print('NO')
	else:
		print('YES')
	q -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = 0
	l = m
	h = m
	ma = m
	mi = m
	flag = 0
	for i in range(n):
		(ti, li, hi) = map(int, input().split())
		if mi - (ti - t) > hi or ma + (ti - t) < li:
			flag = 1
		mi = max(li, mi - (ti - t))
		ma = min(ma + ti - t, hi)
		t = ti
	if flag == 1:
		print('NO')
	else:
		print('YES')


s = int(input(''))
while s > 0:
	t = []
	(n, m) = input('').split()
	n = int(n)
	m = int(m)
	tmax = m
	tmin = m
	time = 0
	ans = 'YES'
	for i in range(0, n):
		l = list(map(int, input('').split()))
		t.append(l)
	for i in range(0, n):
		tmax = tmax + (t[i][0] - time)
		tmin = tmin - (t[i][0] - time)
		time = t[i][0]
		tmax = min(tmax, t[i][2])
		tmin = max(tmin, t[i][1])
		if tmax < tmin:
			ans = 'NO'
			break
	print(ans)
	s = s - 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mMax = m
	mMin = m
	output = 'YES'
	time = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		mMin = mMin - t + time
		mMax = mMax + t - time
		if h < mMin or l > mMax:
			output = 'NO'
		mMin = max(mMin, l)
		mMax = min(mMax, h)
		time = t
	print(output)


def mp():
	return map(int, input().split())
q = int(input())
for _ in range(q):
	(n, m) = mp()
	mn = m
	mx = m
	time = 0
	ans = 'YES'
	for _ in range(n):
		(t, l, h) = mp()
		k = t - time
		mn -= k
		mx += k
		if mn > h or mx < l:
			ans = 'NO'
		time = t
		mn = max(mn, l)
		mx = min(mx, h)
	print(ans)


import math
import sys
from collections import defaultdict, Counter, deque, OrderedDict
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]
from itertools import accumulate, groupby
import sys
mod = 1000000007
for _ in range(int(input())):
	(n, m) = ilele()
	(low, high) = (m, m)
	ti = 0
	f = 0
	for i in range(n):
		(t, l, h) = ilele()
		c = t - ti
		hh = high + c
		ll = low - c
		if hh < l or ll > h:
			f = 1
		low = max(l, ll)
		high = min(h, hh)
		ti = t
	if f == 1:
		print('NO')
	else:
		print('YES')


antalya = int(input())
for kebab in range(antalya):
	(kheys, sueur) = map(int, input().split())
	cmd = []
	cmd.append([0, sueur, sueur])
	for cle in range(kheys):
		(t, l, h) = map(int, input().split())
		if cmd and cmd[-1][0] != t:
			cmd.append([t, l, h])
		else:
			cmd[-1][1] = max(cmd[-1][1], l)
			cmd[-1][2] = min(cmd[-1][2], h)
	kheys = len(cmd)
	cmd.reverse()
	qlf = True
	for i in range(kheys - 1):
		(t, l, h) = cmd[i]
		if l > h:
			qlf = False
			break
		delta = t - cmd[i + 1][0]
		cmd[i + 1][1] = max(cmd[i + 1][1], l - delta)
		cmd[i + 1][2] = min(cmd[i + 1][2], h + delta)
	if cmd[-1][1] > cmd[-1][2]:
		qlf = False
	print('YES' if qlf else 'NO')


def solve(customer, n, mx, mn):
	pre = 0
	for (time, l, r) in customer:
		(mn, mx) = (mn - (time - pre), mx + (time - pre))
		if mn <= r and mx >= l:
			(mn, mx) = (max(mn, l), min(mx, r))
		else:
			return 'NO'
		pre = time
	return 'YES'
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	(mn, mx) = (m, m)
	customer = []
	for i in range(n):
		arr = list(map(int, input().split()))
		customer.append(arr)
	customer.sort(key=lambda x: x[0])
	print(solve(customer, n, mx, mn))


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	(mx, mn) = (m, m)
	c = []
	for _ in range(n):
		c.append(list(map(int, input().split())))
	ans = 'YES'
	prev = 0
	for i in range(n):
		(t, l, h) = c[i]
		mx = mx + t - prev
		mn = mn - (t - prev)
		if mx < l or mn > h:
			ans = 'NO'
			break
		mx = min(mx, h)
		mn = max(mn, l)
		prev = t
	print(ans)


from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
(q,) = rl()
for _ in range(q):
	(n, m) = rl()
	t = 0
	l = h = m
	r = 'YES'
	for i in range(n):
		(ti, li, hi) = rl()
		dt = ti - t
		t = ti
		l = max(l - dt, li)
		h = min(h + dt, hi)
		if l > h:
			r = 'NO'
	print(r)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	mini = m
	maxi = m
	t2 = 0
	b = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		x = mini - (t - t2)
		y = maxi + (t - t2)
		if l <= y and x <= h:
			mini = max(x, l)
			maxi = min(y, h)
			t2 = t
		else:
			b = 1
	else:
		if b:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	array = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		array.append((t, l, h))
	min_reach = m
	max_reach = m
	flag = 0
	prev_t = 0
	for i in range(n):
		(t, l, h) = (array[i][0], array[i][1], array[i][2])
		min_reach -= t - prev_t
		max_reach += t - prev_t
		if min_reach <= l and l <= max_reach:
			min_reach = max(min_reach, l)
			max_reach = min(max_reach, h)
		elif min_reach <= h and h <= max_reach:
			min_reach = max(min_reach, l)
			max_reach = min(max_reach, h)
		elif min_reach <= h and max_reach >= l:
			min_reach = max(min_reach, l)
			max_reach = min(max_reach, h)
		else:
			flag = 1
			break
		prev_t = t
	if flag:
		print('NO')
	else:
		print('YES')


from operator import itemgetter

def solve(customers, m):
	customers.sort(key=itemgetter(0))
	min_temp = m
	max_temp = m
	minutes = 0
	for customer in customers:
		min_temp = min_temp - (customer[0] - minutes)
		max_temp = max_temp + customer[0] - minutes
		if max_temp < customer[1] or min_temp > customer[2]:
			return False
		minutes = customer[0]
		min_temp = max(min_temp, customer[1])
		max_temp = min(max_temp, customer[2])
	return True
for i in range(int(input())):
	(n, m) = map(int, input().split())
	customers = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		customers.append([t, l, h])
	print('YES' if solve(customers, m) else 'NO')


cases = int(input())
for _ in range(cases):
	(n, temp) = [int(i) for i in input().split(' ')]
	time = 0
	minTemp = temp
	maxTemp = temp
	ok = True
	for _ in range(n):
		(cTime, cMin, cMax) = [int(i) for i in input().split(' ')]
		if not ok:
			continue
		deltaTime = cTime - time
		if cMin > minTemp:
			minTemp += deltaTime
			if minTemp > cMin:
				minTemp = cMin
		elif cMin < minTemp:
			minTemp -= deltaTime
		if cMax > maxTemp:
			maxTemp += deltaTime
		elif cMax < maxTemp:
			maxTemp -= deltaTime
			if maxTemp < cMax:
				maxTemp = cMax
		if not (cMin <= maxTemp and cMin >= minTemp or (cMax <= maxTemp and cMax >= minTemp) or (minTemp <= cMax and minTemp >= cMin) or (maxTemp <= cMax and maxTemp >= cMin)):
			print('NO')
			ok = False
		if minTemp < cMin:
			minTemp = cMin
		if maxTemp > cMax:
			maxTemp = cMax
		time = cTime
	if ok:
		print('YES')
		pass


def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		(N, M) = map(int, input().split())
		Tmax = Tmin = M
		t_prev = 0
		ok = 1
		for _ in range(N):
			(t, l, h) = map(int, input().split())
			Tmin -= t - t_prev
			Tmax += t - t_prev
			if l > Tmax or h < Tmin:
				ok = 0
			Tmin = max(l, Tmin)
			Tmax = min(h, Tmax)
			t_prev = t
		if ok:
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = m
	r = m
	t1 = 0
	flag = 0
	for i in range(n):
		(t, l1, r1) = map(int, input().split())
		l = l - (t - t1)
		r = r + (t - t1)
		if r1 >= r and l1 <= r or (l1 <= l and r1 >= l) or (l1 >= l and r1 <= r):
			t1 = t
			l = max(l, l1)
			r = min(r, r1)
		else:
			flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')


def x(a, b, c, d):
	return [max(a, c), min(b, d)]
q = int(input())
for l in range(q):
	(n, m) = map(int, input().split())
	a = m
	b = m
	k = 0
	z = 0
	for l in range(n):
		(t, l, h) = map(int, input().split())
		(a, b) = x(a - (t - z), b + (t - z), l, h)
		z = t
		if b < a:
			k = 1
		if a < l and b < l or (a > h and b > h):
			k = 1
	if k == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	n = L[0]
	m = L[1]
	L2 = []
	for j in range(n):
		ch = input()
		L = [int(i) for i in ch.split()]
		t = L[0]
		l = L[1]
		h = L[2]
		L2.append((t, l, h))
	L2.sort()
	temps = 0
	intv = [m, m]
	test = True
	for j in range(n):
		t = L2[j][0]
		l = L2[j][1]
		h = L2[j][2]
		intv = [intv[0] - (t - temps), intv[1] + (t - temps)]
		if intv[0] > h or intv[1] < l:
			test = False
			break
		else:
			intv = [max(intv[0], l), min(intv[1], h)]
		temps = t
	if test:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for i in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	for j in range(n):
		arr.append(list(map(int, input().split())))
	prev = 0
	Min = Max = m
	flag = True
	for j in arr:
		Min -= j[0] - prev
		Max += j[0] - prev
		if Max < j[1] or Min > j[2]:
			flag = False
			break
		Min = max(Min, j[1])
		Max = min(Max, j[2])
		prev = j[0]
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for destination in range(q):
	(n, m) = map(int, input().split())
	LastTime = 0
	ind1 = m
	ind2 = m
	answer = 'YES'
	for i in range(n):
		(t, l, h) = map(int, input().split())
		ind1 -= t - LastTime
		ind2 += t - LastTime
		LastTime = t
		ind1 = max(l, ind1)
		ind2 = min(h, ind2)
		if ind1 > ind2:
			answer = 'NO'
	print(answer)


def solve(start_pos, arr):
	(cur_r1, cur_r2) = (start_pos, start_pos)
	cur_t = 0
	(min_r1, max_r2) = (start_pos, start_pos)
	for a in arr:
		(t, r1, r2) = a
		min_r1 -= t - cur_t
		max_r2 += t - cur_t
		cur_t = t
		if min_r1 <= r1 and r2 <= max_r2:
			cur_r1 = max(min_r1, r1)
			cur_r2 = min(max_r2, r2)
		elif (min_r1 >= r1 and min_r1 <= r2) and (max_r2 >= r1 and max_r2 <= r2):
			cur_r1 = max(min_r1, r1)
			cur_r2 = min(max_r2, r2)
		elif (min_r1 >= r1 and min_r1 <= r2) and max_r2 >= r2:
			cur_r1 = max(min_r1, r1)
			cur_r2 = min(max_r2, r2)
		elif min_r1 <= r1 and (max_r2 >= r1 and max_r2 <= r2):
			cur_r1 = max(min_r1, r1)
			cur_r2 = min(max_r2, r2)
		elif min_r1 < r1 and max_r2 < r1 or (min_r1 > r2 and max_r2 > r2):
			return 'NO'
		min_r1 = cur_r1
		max_r2 = cur_r2
	return 'YES'
t = int(input())
for _ in range(t):
	(n, start_pos) = map(int, input().split())
	arr = []
	for _ in range(n):
		(a1, a2, a3) = map(int, input().split())
		arr.append([a1, a2, a3])
	print(solve(start_pos, arr))


def solve():
	(n, m) = map(int, input().split())
	t = 0
	mn = mx = m
	flag = True
	for _ in range(n):
		(new_t, l, h) = map(int, input().split())
		timeRem = new_t - t
		mn = mn - timeRem
		mx = mx + timeRem
		if mn > h or mx < l:
			if flag:
				print('NO')
				flag = False
		mn = max(mn, l)
		mx = min(mx, h)
		t = new_t
	if flag:
		print('YES')
		return
t = int(input())
for _ in range(t):
	solve()


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	(time, mx, mn) = (0, m, m)
	flag = True
	for __ in range(n):
		(x, y, z) = map(int, input().split())
		if not flag:
			continue
		mx += x - time
		mn -= x - time
		if mx < y or mn > z:
			flag = False
		if mx > z:
			mx = z
		if mn < y:
			mn = y
		time = x
	print('YES' if flag else 'NO')


q = int(input())
result = []
for _ in range(q):
	(n, m) = input().split(' ')
	n = int(n)
	m = int(m)
	t = [0]
	l = [m]
	h = [m]
	for _ in range(n):
		(a, b, c) = input().split(' ')
		t.append(int(a))
		l.append(int(b))
		h.append(int(c))
	left = m
	right = m
	flag_YES = True
	for i in range(1, n + 1):
		left -= t[i] - t[i - 1]
		right += t[i] - t[i - 1]
		if right < l[i] or h[i] < left:
			flag_YES = False
		else:
			if l[i] > left:
				left = l[i]
			if h[i] < right:
				right = h[i]
	if flag_YES:
		result.append('YES')
	else:
		result.append('NO')
for item in result:
	print(item)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, temp) = map(int, input().split())
		first = 0
		(min, max) = (temp, temp)
		ans = True
		for _ in range(n):
			(t, l, r) = map(int, input().split())
			dif = t - first
			first = t
			min = min - dif
			max = max + dif
			if min <= l and r <= max:
				(min, max) = (l, r)
			elif max < l or min > r:
				ans = False
			elif max >= r:
				max = r
			elif min <= l:
				min = l
		if ans:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.readline
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	ans = [[0, 0, 0]]
	time = [0]
	for i in range(x):
		z = list(map(int, input().split()))
		ans.append(z)
	ans.sort(key=lambda x: x[0])
	for i in range(1, len(ans)):
		time.append(ans[i][0] - ans[i - 1][0])
	l = y
	r = y
	flag = 0
	for i in range(1, len(time)):
		l = l - time[i]
		r = r + time[i]
		if ans[i][2] < l or ans[i][1] > r:
			flag = 1
			break
		else:
			l = max(l, ans[i][1])
			r = min(r, ans[i][2])
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
q = int(input())
for ii in range(q):
	(n, m) = map(int, input().split())
	tlh = []
	for i in range(n):
		tlh.append(list(map(int, input().split())))
	f = 0
	tp = 0
	nl = m
	nr = m
	for i in range(n):
		t = tlh[i][0]
		l = tlh[i][1]
		h = tlh[i][2]
		tm = t - tp
		if nl - tm <= l <= nr + tm:
			nl = l
			nr = min(nr + tm, h)
		elif nl - tm <= h <= nr + tm:
			nl = max(nl - tm, l)
			nr = h
		elif l <= nl - tm <= nr + tm <= h:
			nl = nl - tm
			nr = nr + tm
		else:
			f = 1
			break
		tp = t
	if f == 1:
		print('NO')
	else:
		print('YES')


import sys

def fn1(rngprev, tprev, ti, lo, hi):
	dt = ti - tprev
	if hi < rngprev[0] - dt:
		return None
	if rngprev[1] + dt < lo:
		return None
	return [max(lo, rngprev[0] - dt), min(hi, rngprev[1] + dt)]

def fn0():
	res = True
	(ps, t0) = [int(i) for i in input().split(' ')]
	tprev = 0
	rngprev = [t0, t0]
	for p in range(ps):
		(ti, lo, hi) = [int(i) for i in input().split(' ')]
		if res:
			rng = fn1(rngprev, tprev, ti, lo, hi)
			if rng is None:
				res = False
			rngprev = rng
			tprev = ti
	return res
for i in range(int(input())):
	if fn0():
		print('YES')
	else:
		print('NO')


def aircon(n, m, custs):
	current_range = (m, m)
	current_time = 0
	for (t, l, h) in custs:
		selisih_waktu = t - current_time
		current_time = t
		try:
			current_range = intersect(current_range[0] - selisih_waktu, current_range[1] + selisih_waktu, l, h)
		except ValueError:
			print('NO')
			return
	print('YES')

def intersect(a, b, c, d):
	l = max(a, c)
	h = min(b, d)
	if l > h:
		raise ValueError()
	return (l, h)
t = int(input())
for __ in range(t):
	(n, m) = map(int, input().split())
	custs = []
	for cust_num in range(n):
		custs.append(list(map(int, input().split())))
	aircon(n, m, custs)


inp = lambda : map(int, input().split(' '))
q = int(input())

def intersection(x, y, *points):
	(smallest, largest) = (float('inf'), float('-inf'))
	for p in points:
		if x <= p <= y:
			smallest = min(smallest, p)
			largest = max(largest, p)
		elif p > y:
			largest = y
		elif p < x:
			smallest = x
	return (smallest, largest)

def possible(first, second):
	diff = second[0] - first[0]
	(a1, a2) = (second[1] - diff, second[2] - diff)
	(b1, b2) = (second[1] + diff, second[2] + diff)
	(a, b) = (first[1], first[2])
	inter = intersection(a, b, a1, a2, b1, b2)
	if inter[0] == float('inf') or inter[1] == float('-inf'):
		return False
	first[1] = inter[0]
	first[2] = inter[1]
	return True
for _ in range(q):
	(n, m) = inp()
	customers = []
	customers.append([0, m, m])
	for i in range(n):
		(t, l, h) = inp()
		customers.append([t, l, h])
	flag = True
	for i in range(n + 1)[::-1]:
		(second, first) = (customers[i], customers[i - 1])
		if i == 0:
			break
		f = possible(first, second)
		if not f:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
while q:
	(n, m) = map(int, input().split())
	flag = True
	ls = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		ls.append([l, h, t])
	max_temp = m
	min_temp = m
	for i in range(n):
		if i == 0:
			max_temp = max_temp + ls[i][2]
			min_temp = min_temp - ls[i][2]
			if max_temp < ls[i][0] or min_temp > ls[i][1]:
				flag = False
				break
			else:
				max_temp = min(max_temp, ls[i][1])
				min_temp = max(min_temp, ls[i][0])
		else:
			max_temp = max_temp + (ls[i][2] - ls[i - 1][2])
			min_temp = min_temp - (ls[i][2] - ls[i - 1][2])
			if max_temp < ls[i][0] or min_temp > ls[i][1]:
				flag = False
				break
			else:
				max_temp = min(max_temp, ls[i][1])
				min_temp = max(min_temp, ls[i][0])
	if flag:
		print('YES')
	else:
		print('NO')
	q -= 1


r = int(input())
for _ in range(r):
	(n, m) = map(int, input().split())
	l1 = m
	h1 = m
	t1 = 0
	flag = True
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		d = t - t1
		if h1 + d < l:
			flag = False
		if l1 - d > h:
			flag = False
		if l < l1 - d:
			l1 = l1 - d
		else:
			l1 = l
		if h > h1 + d:
			h1 = h1 + d
		else:
			h1 = h
		t1 = t
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	it = [list(map(int, input().split())) for i in range(n)]
	l = m
	r = m
	prev = 0
	st = 0
	for i in range(n):
		l -= it[i][0] - prev
		r += it[i][0] - prev
		if r < it[i][1]:
			st = 1
			break
		elif l > it[i][2]:
			st = 1
			break
		l = max(l, it[i][1])
		r = min(r, it[i][2])
		prev = it[i][0]
	if st:
		print('NO')
	else:
		print('YES')


T = int(input())
for test in range(T):
	(N, M) = list(map(int, input().split()))
	(timearray, boundsarray) = ([], [])
	verdict = 'YES'
	for person in range(N):
		(t, l, h) = list(map(int, input().split()))
		logged = False
		if person > 0:
			t0 = timearray[-1]
		else:
			t0 = -1
		if t == t0:
			(l0, h0) = boundsarray[-1]
			(lp, hp) = (max(l0, l), min(h0, h))
			if lp > hp:
				verdict = 'NO'
			boundsarray[-1] = (lp, hp)
			logged = True
		else:
			timearray.append(t)
			boundsarray.append((l, h))
	if verdict == 'NO':
		print(verdict)
		continue
	distinct = len(timearray)
	tdarray = [timearray[0] if i == 0 else timearray[i] - timearray[i - 1] for i in range(distinct)]
	(Tlower, Tupper) = (M, M)
	for i in range(distinct):
		t = tdarray[i]
		Tlower -= t
		Tupper += t
		(l, h) = boundsarray[i]
		if l > Tupper or h < Tlower:
			verdict = 'NO'
			break
		Tupper = min(Tupper, h)
		Tlower = max(Tlower, l)
	print(verdict)


import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
go = lambda : 1 / 0

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}{}'.format(i, sep))
INF = float('inf')
MOD = int(1000000000.0 + 7)
YES = 'YES'
NO = 'NO'

def intersect(a, b):
	(a, b) = sorted([a, b])
	if a[0] < b[0] and a[1] < b[0]:
		return []
	elif a[0] <= b[0] and a[1] >= b[0]:
		return [b[0], min(a[1], b[1])]
	else:
		print('???')
		raise ConnectionError()
for _ in range(int(input())):
	try:
		(n, m) = read()
		arr = sorted([read() for i in range(n)])
		cur_time = 0
		cur_temp = [m, m]
		for (t, l, r) in arr:
			x = t - cur_time
			temp = intersect([l, r], [cur_temp[0] - x, cur_temp[1] + x])
			if temp:
				cur_temp = temp
			else:
				print(NO)
				go()
			cur_time = t
		print(YES)
	except ZeroDivisionError:
		continue
	except Exception as e:
		print(e)
		continue


from sys import stdin
from collections import defaultdict
input = stdin.readline

def merge1(x, y):
	if x[0] > y[0]:
		(x, y) = (y, x)
	if x[0] == y[0]:
		return [x[0], min(x[1], y[1])]
	if x[1] < y[0]:
		return -1
	return [y[0], min(x[1], y[1])]

def merge2(x, y):
	return [max(x[0], y[0]), min(x[1], y[1])]

def meth(a, mn, mx, pval):
	if len(a) == 0:
		return True
	rng = [mn - a[0][0] + pval, mx + a[0][0] - pval]
	if merge1(rng, [a[0][1], a[0][2]]) == -1:
		return False
	valll = merge1(rng, [a[0][1], a[0][2]])
	return meth(a[1:], valll[0], valll[1], a[0][0])
t = int(input())
for _ in range(t):
	(n, T) = list(map(int, input().split()))
	a = []
	dict1 = defaultdict(list)
	flag1 = 0
	for __ in range(n):
		(t, l, r) = list(map(int, input().split()))
		if flag1 == -1:
			continue
		if dict1[t] == []:
			dict1[t] = [l, r]
		else:
			prev = dict1[t]
			curr = [l, r]
			dict1[t] = merge1(prev, curr)
			if dict1[t] == -1:
				flag1 = -1
	if flag1 == -1:
		print('NO')
		continue
	for x in dict1:
		a.append([x, dict1[x][0], dict1[x][1]])
	a.sort()
	if meth(a, T, T, 0):
		print('YES')
	else:
		print('NO')


def check_sat(clients, initial_temp):
	upper = lower = initial_temp
	time = 0
	for client in clients:
		(client_visit, client_lower, client_upper) = client
		delta = client_visit - time
		time = client_visit
		(lower, upper) = (lower - delta, upper + delta)
		if upper < client_lower:
			return False
		if lower > client_upper:
			return False
		upper = min(client_upper, upper)
		lower = max(client_lower, lower)
	return True
testcases = int(input())
for _ in range(testcases):
	(n, m) = [int(p) for p in input().split()]
	clients = []
	for _ in range(n):
		(timevisit, lower, upper) = [int(p) for p in input().split()]
		clients.append((timevisit, lower, upper))
	if check_sat(clients, m):
		print('YES')
	else:
		print('NO')


import sys
Q = int(sys.stdin.readline().strip())
for q in range(0, Q):
	(n, m) = list(map(int, sys.stdin.readline().strip().split()))
	M = [[0 for j in range(0, 3)] for i in range(0, n)]
	for i in range(0, n):
		(M[i][0], M[i][1], M[i][2]) = list(map(int, sys.stdin.readline().strip().split()))
	M.sort()
	t = 0
	l = m
	h = m
	v = True
	for i in range(0, n):
		t2 = M[i][0]
		l2 = M[i][1]
		h2 = M[i][2]
		l = max(l2, l - t2 + t)
		h = min(h2, h + t2 - t)
		t = t2
		if h < l:
			v = False
	if v == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(lo, hi) = (m, m)
	t0 = 0
	ans = 'YES'
	for __ in range(n):
		(t, l, h) = map(int, input().split())
		lo -= t - t0
		hi += t - t0
		t0 = t
		(lo, hi) = (max(lo, l), min(hi, h))
		if lo > hi:
			ans = 'NO'
	print(ans)


def check(mn, mx, a, b):
	if mn > b or mx < a:
		return None
	else:
		return [max(a, mn), min(b, mx)]
for _ in range(int(input())):
	arr = []
	(n, m) = [int(i) for i in input().split()]
	for x in range(n):
		arr.append([int(i) for i in input().split()])
	temp = [m, m]
	t = 0
	ans = True
	for i in arr:
		intr = i[0] - t
		mx = temp[1] + intr
		mn = temp[0] - intr
		temp = check(mn, mx, i[1], i[2])
		if temp == None:
			ans = False
			break
		else:
			t = i[0]
	if ans == True:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append([int(i) for i in input().split()])
	arr.sort(key=lambda x: x[0])
	flag = 0
	t1 = m
	t2 = m
	time = 0
	for i in arr:
		g = i[0] - time
		t1 = max(t1 - g, i[1])
		t2 = min(t2 + g, i[2])
		time = i[0]
		if t1 > t2:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
for _ in range(int(cin())):
	(n, m) = map(int, cin().split())
	f = 0
	high = m
	low = m
	temp = 0
	for i in range(n):
		(t, l, h) = map(int, cin().split())
		if not f:
			low = max(l, low - t + temp)
			high = min(h, high + t - temp)
			temp = t
			if low > high:
				cout('no\n')
				f = 1
	if not f:
		cout('yes\n')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	mi = ma = m
	prev = 0
	aa = [list(map(int, input().split())) for _ in range(n)]
	aa.sort()
	for i in range(n):
		(t, l, h) = aa[i]
		mi = max(mi - (t - prev), l)
		ma = min(ma + (t - prev), h)
		prev = t
		if h < mi or l > ma:
			print('NO')
			break
	else:
		print('YES')


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	(n, m) = map(int, input().split())
	cus = []
	for i in range(n):
		cus.append(list(map(int, input().split())))
	(l, e) = (m, m)
	p = 0
	ans = 'YES'
	for i in range(n):
		l -= cus[i][0] - p
		e += cus[i][0] - p
		l = max(l, cus[i][1])
		e = min(e, cus[i][2])
		p = cus[i][0]
		if e < l:
			ans = 'NO'
			break
	print(ans)


import sys
from pprint import pprint
if not 'DEBUG' in globals():
	readline = sys.stdin.readline

def read(map_func):
	return map_func(readline().rstrip())

def reads(map_func):
	return list(map(map_func, readline().rstrip().split()))

def readn(map_func, n):
	return [map_func(readline().rstrip()) for _ in range(n)]

def readint():
	return read(int)

def readints():
	return reads(int)

def readcol(n):
	return readn(int, n)

def readmat(n):
	return [readints() for _ in range(n)]

def readmap(n):
	return readn(list, n)

def makemat(n, m, v):
	return [[v for _ in range(m)] for _ in range(n)]

def zeromat(n, m=None):
	return makemat(n, m if m else n, 0)

def listmat(n, m=None):
	return [[[] for _ in range(m if m else n)] for _ in range(n)]

def crosslist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x), (y, x - 1), (y + 1, x)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def roundlist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x + 1), (y - 1, x), (y - 1, x - 1), (y, x - 1), (y + 1, x - 1), (y + 1, x), (y + 1, x + 1)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def plog(obj):
	pprint(obj) if 'DEBUG' in globals() else None

def log(msg, label=None):
	print((label + ': ' if label else '') + str(msg)) if 'DEBUG' in globals() else None

def _logmat(mat, label=None):
	fmt = '{:' + str(max((max((len(str(s)) for s in m)) for m in mat))) + 'd}'
	f = lambda row: '[' + ' '.join((fmt.format(x) for x in row)) + ']'
	[log('[' + f(row), label) if i == 0 else log((' ' * (len(label) + 3) if label else ' ') + f(row) + ']', None) if i == len(mat) - 1 else log((' ' * (len(label) + 3) if label else ' ') + f(row), None) for (i, row) in enumerate(mat)]

def logmat(mat, label=None):
	_logmat(mat, label) if 'DEBUG' in globals() else None
for _ in range(readint()):
	(N, M) = readints()
	(s, e) = (M, M)
	p = 0
	for (t, l, h) in readmat(N):
		s -= t - p
		e += t - p
		p = t
		s = max(s, l)
		e = min(e, h)
		if e < s:
			print('NO')
			break
	else:
		print('YES')


q = int(input())
for _ in range(q):
	[n, m] = [*map(int, input().split())]
	prevt = 0
	maxi = m
	mini = m
	res = 'YES'
	for _ in range(n):
		[t, l, h] = [*map(int, input().split())]
		maxi = maxi + t - prevt
		mini = mini - t + prevt
		if maxi < l or mini > h:
			res = 'NO'
		maxi = min(h, maxi)
		mini = max(l, mini)
		prevt = t
	print(res)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, intemp) = map(int, input().split())
	l = []
	for i in range(n):
		(t, li, h) = map(int, input().split())
		l += [[t, li, h]]
	overh = l[-1][2]
	overl = l[-1][1]
	flag = 0
	for i in range(n - 2, -1, -1):
		overh = overh + l[i + 1][0] - l[i][0]
		overl = overl - (l[i + 1][0] - l[i][0])
		x = [[overl, overh], [l[i][1], l[i][2]]]
		x.sort()
		if x[0][1] < x[1][0]:
			flag = 1
			break
		else:
			overh = min(x[1][1], x[0][1])
			overl = x[1][0]
	overh = overh + l[i][0]
	overl = overl - l[i][0]
	if flag == 0 and overl <= intemp and (intemp <= overh):
		print('YES')
	else:
		print('NO')


f = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, m) = f()
	pt = 0
	pl = pu = m
	flag = 1
	for i in range(n):
		(ct, cl, cu) = f()
		t = ct - pt
		if cl > pu and abs(cl - pu) > t:
			flag = 0
		if cu < pl and abs(cu - pl) > t:
			flag = 0
		pl = max(pl - t, cl)
		pu = min(pu + t, cu)
		pt = ct
	print('YES') if flag else print('NO')


def tc():
	(n, m) = map(int, input().split())
	ppl = [tuple(map(int, input().split())) for _ in range(n)]
	time = 0
	(ltemp, htemp) = (m, m)
	for (t, l, h) in ppl:
		dt = t - time
		if htemp + dt < l or ltemp - dt > h:
			print('NO')
			return
		ltemp = max(l, ltemp - dt)
		htemp = min(h, htemp + dt)
		time = t
	print('YES')
T = int(input())
for _ in range(T):
	tc()


import sys

def f(args, l, u, t, i):
	if i == len(args):
		print('Yes')
		return
	line = str.split(args[i])
	ti = int(line[0])
	li = int(line[1])
	ui = int(line[2])
	if not (li > u + (ti - t) or ui < l - (ti - t)):
		return f(args, max(li, l - (ti - t)), min(ui, u + (ti - t)), ti, i + 1)
	else:
		print('No')
		return False
index = 0
args = []
x = 0
flag = 0
cnt = 0
for line in sys.stdin:
	if flag == 0:
		flag += 1
		continue
	elif flag == 1:
		flag += 1
		x = int(str.split(line)[0])
		startTmp = int(str.split(line)[1])
	elif index < x - 1:
		args.append(line)
		index += 1
	else:
		args.append(line)
		f(args, startTmp, startTmp, 0, 0)
		args.clear()
		index = 0
		flag = 1


t = int(input())
for _ in range(t):
	arr = []
	(q, stemp) = [int(x) for x in input().strip().split()]
	for data in range(q):
		(ti, l, h) = [int(x) for x in input().strip().split()]
		arr.append((ti, l, h))
	arr.reverse()
	flag = True
	i = 0
	l = arr[0][1]
	h = arr[0][2]
	while i < q - 1:
		tdiff = arr[i][0] - arr[i + 1][0]
		n_l = l - tdiff
		n_h = h + tdiff
		if arr[i + 1][2] < n_l or arr[i + 1][1] > n_h:
			flag = False
			break
		else:
			l = max(n_l, arr[i + 1][1])
			h = min(n_h, arr[i + 1][2])
		i += 1
	l = l - arr[-1][0]
	h = h + arr[-1][0]
	if flag and stemp >= l and (stemp <= h):
		print('YES')
	else:
		print('NO')


R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, m) = R()
	lst = (0, m, m)
	is_good = 1
	for i in range(n):
		cur = list(R())
		(l1, r1) = (lst[1] - (cur[0] - lst[0]), lst[2] + (cur[0] - lst[0]))
		if cur[1] <= l1 <= cur[2]:
			lst = [cur[0], l1, min(cur[2], r1)]
		elif l1 <= cur[1] <= r1:
			lst = [cur[0], cur[1], min(cur[2], r1)]
		else:
			is_good = 0
	if is_good:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	left = m
	right = m
	ans = True
	last = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		temp = t
		t = t - last
		last = temp
		left = min(left, left - t)
		right = max(right, right + t)
		d = min(right, h) - max(left, l)
		if d < 0:
			ans = False
		else:
			left = max(left, l)
			right = min(right, h)
	if ans:
		print('YES')
	else:
		print('NO')


cases = int(input())
for _ in range(cases):
	(n, temp) = [int(x) for x in input().split()]
	cust = []
	lo = temp
	hi = temp
	prev = 0
	possible = True
	for _ in range(n):
		(t, l, h) = [int(x) for x in input().split()]
		if not possible:
			continue
		gap = t - prev
		lo -= gap
		hi += gap
		if l > lo:
			lo = l
		if h < hi:
			hi = h
		if lo > hi:
			possible = False
		prev = t
	print('YES' if possible else 'NO')


def insect(a, b):
	if b[0] > a[1] or a[0] > b[1]:
		return None
	else:
		return [max(b[0], a[0]), min(a[1], b[1])]
for _ in range(int(input())):
	ans = True
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for i in range(n)]
	b = dict()
	c = set()
	for i in a:
		c.add(i[0])
		b[i[0]] = None
	for i in a:
		if b[i[0]] == None:
			b[i[0]] = [i[1], i[2]]
		elif i[1] > b[i[0]][1] or b[i[0]][0] > i[2]:
			ans = False
			break
		else:
			b[i[0]] = [max(i[1], b[i[0]][0]), min(i[2], b[i[0]][1])]
	if not ans:
		print('NO')
		continue
	k = 0
	prev = None
	for i in b:
		if k == 0:
			k = 1
			possible_temp = [m - i, m + i]
			final_temp = insect(possible_temp, b[i])
			if final_temp == None:
				ans = False
				break
			prev = i
			b[i] = final_temp
			continue
		possible_temp = [b[prev][0] - (i - prev), b[prev][1] + (i - prev)]
		final_temp = insect(possible_temp, b[i])
		if final_temp == None:
			ans = False
			break
		prev = i
		b[i] = final_temp
	if not ans:
		print('NO')
	else:
		print('YES')


for q in range(int(input())):
	(n, m) = map(int, input().split())
	low = m
	high = m
	prev = 0
	c = 0
	l = []
	for i in range(n):
		l.append(list(map(int, input().split())))
	for i in range(n):
		temp = l[i]
		tim = temp[0] - prev
		low -= tim
		high += tim
		c = i
		prev = temp[0]
		if high < temp[1] or low > temp[2]:
			print('NO')
			break
		low = max(low, temp[1])
		high = min(high, temp[2])
	else:
		print('YES')


t = int(input())
for test in range(t):
	(n, m) = map(int, input().split())
	th = m
	tl = m
	lt = 0
	flag = True
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if l > th + (t - lt) or h < tl - (t - lt):
			flag = False
		tl = max(l, tl - (t - lt))
		th = min(h, th + (t - lt))
		lt = t
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for u in range(q):
	(n, nach) = [int(i) for i in input().split()]
	gosti = []
	non = 0
	for i in range(n):
		gosti.append([int(i) for i in input().split()])
	(tmin, tmax) = (nach, nach)
	nn = 0
	for i in range(n):
		g = gosti[i]
		tmin -= g[0] - nn
		tmax += g[0] - nn
		if tmin <= g[1] and non == 0:
			if tmax < g[1]:
				non = 1
			elif tmax >= g[2]:
				(tmin, tmax) = (g[1], g[2])
			else:
				tmin = g[1]
		elif non == 0:
			if tmin > g[2]:
				non = 1
			elif tmax >= g[2]:
				tmax = g[2]
		nn = g[0]
	if non == 1:
		print('NO')
	else:
		print('YES')


def f(s):
	return s == s[::-1]
for _ in range(int(input())):
	(n, t0) = map(int, input().split())
	(mn, mx) = (t0, t0)
	ans = True
	prev = 0
	for _ in range(n):
		(t, tl, th) = map(int, input().split())
		mn = mn - (t - prev)
		mx = mx + (t - prev)
		if mx < tl or mn > th:
			ans = False
		if mn < tl:
			mn = tl
		if mx > th:
			mx = th
		prev = t
	if ans:
		print('YES')
	else:
		print('NO')


def cal(tlhs, pl):
	ph = pl
	pt = 0
	for (t, l, h) in tlhs:
		diff = t - pt
		nl = max(pl - diff, l)
		nh = min(ph + diff, h)
		if nl > nh:
			return 'NO'
		pl = nl
		ph = nh
		pt = t
	return 'YES'
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	tlhs = [tuple(map(int, input().split())) for _ in range(n)]
	print(cal(tlhs, m))


from copy import copy
from math import *

def arr_float_inp():
	return [float(s) for s in input().split()]

def arr_int_inp():
	return [int(s) for s in input().split()]

def int_inp():
	return int(input())

def float_inp():
	return float(input())

def comp(a):
	return a[0]

def gcd(a, b):
	if b != 0:
		return gcd(b, a % b)
	else:
		return a

def lcm(a, b):
	a / gcd(a, b) * b
for _ in range(int_inp()):
	(n, current_temp) = arr_int_inp()
	current_temp = [current_temp, current_temp]
	current_time = 0
	flag = True
	for i in range(n):
		(t, l, h) = arr_int_inp()
		if not flag:
			continue
		min_v = current_temp[0] - (t - current_time)
		max_v = current_temp[1] + (t - current_time)
		if max_v < l or min_v > h:
			flag = False
		else:
			current_temp[0] = max(min_v, l)
			current_temp[1] = min(max_v, h)
		current_time = t
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	T = 0
	L = m
	H = m
	flag = False
	for i in range(n):
		(t, l, h) = map(int, input().split())
		L = max(L - (t - T), l)
		H = min(H + (t - T), h)
		T = t
		if L > h or H < l:
			flag = True
	if flag:
		print('NO')
	else:
		print('YES')


kl = int(input())
for l in range(kl):
	(n, m) = [int(i) for i in input().split()]
	tx = m
	tn = m
	t = 0
	pr = 0
	st = 0
	for i in range(n):
		(s, nt, vt) = [int(i) for i in input().split()]
		if pr:
			continue
		if tx + (s - st) < nt or tn - (s - st) > vt:
			pr = 1
		else:
			tx = min(tx + (s - st), vt)
			tn = max(tn - (s - st), nt)
			st = s
	if pr:
		print('NO')
	else:
		print('YES')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	th = tl = m
	t0 = 0
	s = 'YES'
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		th = min(h, th + t - t0)
		tl = max(l, tl - t + t0)
		t0 = t
		if th < l or tl > h:
			s = 'NO'
	print(s)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ll = []
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		ll.append((t, l, h))
	ll.sort()
	time = 0
	mn = m
	mx = m
	f = True
	for i in range(n):
		curr = ll[i]
		future = curr[0]
		mn = mn - (future - time)
		mx = mx + future - time
		if mx < curr[1]:
			f = False
			break
		if mn > curr[2]:
			f = False
			break
		if mn < curr[1]:
			mn = curr[1]
		if mx > curr[2]:
			mx = curr[2]
		time = future
	if f:
		print('YES')
	else:
		print('NO')


def intersect(a, b, c, d):
	if b < c or a > d:
		return 0
	return 1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = 0
	mini = m
	maxi = m
	index = 0
	f = 1
	for i in range(n):
		(t1, l, h) = list(map(int, input().split()))
		mini = mini - (t1 - t)
		maxi = maxi + (t1 - t)
		t = t1
		if intersect(mini, maxi, l, h):
			mini = max(mini, l)
			maxi = min(maxi, h)
			index += 1
		else:
			f = 0
	if f == 1:
		print('YES')
	else:
		print('NO')


R = lambda : map(int, input().split())
(q,) = R()
for _ in [0] * q:
	(n, a) = R()
	b = a
	s = 0
	r = 'YES'
	for _ in [0] * n:
		(t, l, h) = R()
		d = t - s
		s = t
		a = max(l, a - d)
		b = min(h, b + d)
		if a > b:
			r = 'NO'
	print(r)


def func(intervals, N):
	l = intervals[0][0]
	r = intervals[0][1]
	for i in range(1, N):
		if intervals[i][0] > r or intervals[i][1] < l:
			return -1
		else:
			l = max(l, intervals[i][0])
			r = min(r, intervals[i][1])
	return [l, r]
intervals = [[2, 15], [16, 20]]
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = []
	for i in range(n):
		x = list(map(int, input().split()))
		arr.append(x)
	f = 0
	(lt, ht) = (m, m)
	time = 0
	for i in range(n):
		(t, l, h) = (arr[i][0], arr[i][1], arr[i][2])
		diff = t - time
		lt = lt - diff
		ht = ht + diff
		intervals = [[lt, ht], [l, h]]
		x = func(intervals, 2)
		if x == -1:
			f = 1
			break
		else:
			(lt, ht) = (x[0], x[1])
		time = t
	if f == 1:
		print('NO')
	else:
		print('YES')


def overlap(l, r, i, j):
	return not (r < i or l > j)

def solve(n, m, arr):
	(l, r) = (m, m)
	cur_t = 0
	for (t, i, j) in arr:
		d = t - cur_t
		(l, r) = (l - d, r + d)
		if not overlap(l, r, i, j):
			print('NO')
			return
		(l, r) = (max(l, i), min(r, j))
		cur_t = t
	print('YES')

def main():
	inp = lambda : [int(x) for x in input().split()]
	tc = int(input())
	for _ in range(tc):
		(n, m) = inp()
		arr = [inp() for _ in range(n)]
		solve(n, m, arr)
main()


def solve():
	line1 = list(map(lambda x: int(x), input().split()))
	n = line1[0]
	initial_temp = line1[1]
	temp_low = initial_temp
	temp_high = initial_temp
	time = 0
	possible = True
	for i in range(0, n):
		if possible == False:
			input()
			continue
		linei = list(map(lambda x: int(x), input().split()))
		t = linei[0]
		required_low = linei[1]
		required_high = linei[2]
		possible_low = temp_low - (t - time)
		possible_high = temp_high + (t - time)
		if required_low > possible_high or required_high < possible_low:
			possible = False
			continue
		time = t
		temp_low = max(required_low, possible_low)
		temp_high = min(required_high, possible_high)
	if possible:
		print('YES')
	else:
		print('NO')
q = int(input())
for i in range(0, q):
	solve()


q = int(input())
for _ in range(q):
	(n, m) = list(map(int, input().split()))
	t = [0]
	l = []
	h = []
	for i in range(n):
		(ti, li, hi) = list(map(int, input().split()))
		t.append(ti)
		l.append(li)
		h.append(hi)
	hmax = m
	lmin = m
	ans = True
	for i in range(n):
		hmax = hmax + (t[i + 1] - t[i])
		lmin = lmin - (t[i + 1] - t[i])
		if lmin > h[i] or hmax < l[i]:
			ans = False
			break
		else:
			if h[i] <= hmax:
				hmax = h[i]
			if l[i] >= lmin:
				lmin = l[i]
	print('YES' if ans else 'NO')


q = int(input())
for t in range(q):
	(n, m) = [int(x) for x in input().split()]
	c = []
	for i in range(n):
		c.append([int(x) for x in input().split()])
	c.sort(key=lambda x: (x[0], -x[1], x[2]))
	f = 0
	ctime = 0
	ml = m
	mr = m
	for i in range(n):
		t = c[i][0]
		l = c[i][1]
		r = c[i][2]
		timel = t - ctime
		if ml - timel <= r and mr + timel >= l:
			ml = max(ml - timel, l)
			mr = min(mr + timel, r)
			ctime = t
			continue
		else:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	(mi, ma) = (y, y)
	p = 0
	al = 0
	for j in range(x):
		(a, b, c) = map(int, input().split())
		mi -= a - al
		ma += a - al
		if mi >= b and mi <= c:
			if ma > c:
				ma = c
		elif ma >= b and ma <= c:
			if mi < b:
				mi = b
		elif ma >= c and mi <= b:
			mi = b
			ma = c
		else:
			p = 1
		al = a
	if p == 0:
		print('YES')
	else:
		print('NO')


def satisfyCustomers(customers):
	(i, n) = (1, len(customers))
	possible = [customers[0][1], customers[0][1]]
	prevTime = customers[0][0]
	while i < n:
		difference = customers[i][0] - prevTime
		minTime = customers[i][1]
		maxTime = customers[i][2]
		lo = possible[0] - difference
		hi = possible[1] + difference
		new_lo = max(minTime, lo)
		new_hi = min(maxTime, hi)
		if new_hi < new_lo:
			return False
		prevTime = customers[i][0]
		possible = [new_lo, new_hi]
		i += 1
	return True
testCases = int(input())
for _ in range(testCases):
	(n, m) = map(int, input().split())
	customers = [(0, m, m)]
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		customers.append([t, l, h])
	print('YES') if satisfyCustomers(customers) else print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split(' '))
	(start, end) = (m, m)
	curr_t = 0
	res = True
	for _ in range(n):
		(t, l, h) = map(int, input().split(' '))
		start -= t - curr_t
		end += t - curr_t
		curr_t = t
		start = max(start, l)
		end = min(end, h)
		if end < start:
			res = False
	print('Yes' if res else 'No')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	time = 0
	c = m
	result = 'YES'
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		r = t - time
		time = t
		m = max(l, m - r)
		c = min(h, c + r)
		if m > c:
			result = 'NO'
	print(result)


import sys
for _ in range(int(sys.stdin.readline().rstrip())):
	(n, m) = list(map(int, sys.stdin.readline().rstrip().split()))
	ppl = [[0, m, m]]
	for _ in range(n):
		ppl.append(list(map(int, sys.stdin.readline().rstrip().split())))
	i = 0
	x = m
	y = m
	enabled = True
	last = 0
	for p in ppl:
		diff = p[0] - last
		if x - diff > p[2] or y + diff < p[1]:
			enabled = False
			break
		x = max(x - diff, p[1])
		y = min(y + diff, p[2])
		last = p[0]
	if enabled:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	d = []
	(lb, ub) = (m, m)
	for i in range(n):
		d.append(list(map(int, input().split())))
	d.sort()
	pre_t = 0
	ok = True
	for (t, l, h) in d:
		lb -= t - pre_t
		ub += t - pre_t
		if lb > h or ub < l:
			ok = False
			break
		lb = max(lb, l)
		ub = min(ub, h)
		pre_t = t
	if ok:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	ar = [[0, -10 ** 9, 10 ** 9]]
	for ______ in range(n):
		ar.append(list(map(int, input().split())))
	ar.sort()
	(left, right) = (m, m)
	ans = 'YES'
	for i in range(1, n + 1):
		left -= ar[i][0] - ar[i - 1][0]
		right += ar[i][0] - ar[i - 1][0]
		(left, right) = [max(left, ar[i][1]), min(right, ar[i][2])]
		if right - left < 0:
			ans = 'NO'
	print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	predt = 0
	max_ = m
	min_ = m
	ans = 'YES'
	for i in range(n):
		(t, l, h) = map(int, input().split())
		max_ += t - predt
		min_ -= t - predt
		if min_ <= h and max_ >= l:
			min_ = max(min_, l)
			max_ = min(max_, h)
		else:
			ans = 'NO'
		predt = t
	print(ans)


import math
import collections
import functools
import sys
import os

def solve():
	(n, m) = map(int, input().split())
	table = []
	for _ in range(n):
		temp = list(map(int, input().split()))
		table.append(temp)
	(s, e, pre) = (m, m, 0)
	for (t, l, h) in table:
		s -= t - pre
		e += t - pre
		pre = t
		if s > h or e < l:
			print('NO')
			return
		s = max(s, l)
		e = min(e, h)
	print('YES')

def main():
	T = 1
	T = int(input())
	while T:
		solve()
		T -= 1
main()


q = int(input())
for _ in range(q):
	(n, m) = list(map(int, input().split(' ')))
	status = True
	current_time = 0
	(m_min, m_max) = (None, None)
	for i in range(n):
		(t, l, h) = list(map(int, input().split(' ')))
		if not status:
			continue
		if m_min == None and m_max == None:
			m_min = m - (t - current_time)
			m_max = m + (t - current_time)
		else:
			m_min = m_min - (t - current_time)
			m_max = m_max + (t - current_time)
		m_min = max(l, m_min)
		m_max = min(h, m_max)
		current_time = t
		if m_min > m_max:
			print('NO')
			status = False
	if status:
		print('YES')


q = int(input())
while q:
	q -= 1
	(n, m) = map(int, input().split())
	mn = mx = m
	m = 0
	flag = 1
	while n:
		n -= 1
		(t, l, h) = map(int, input().split())
		span = t - m
		m = t
		mn -= span
		mx += span
		if h >= mn and l <= mx:
			mn = max(mn, l)
			mx = min(mx, h)
		else:
			flag = 0
			break
	if not flag:
		while n:
			n -= 1
			input()
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for i in range(n)]
	(now, nowl, nowh) = (0, m, m)
	for i in range(n):
		(t, l, h) = a[i]
		d = t - now
		nowl -= d
		nowh += d
		if l > nowh or h < nowl:
			print('NO')
			break
		nowl = max(nowl, l)
		nowh = min(nowh, h)
		now = t
	else:
		print('YES')


q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	bul = True
	d_min = m
	d_max = m
	now_t = 0
	for j in range(n):
		(t, l, h) = map(int, input().split())
		if bul:
			d_min -= t - now_t
			d_max += t - now_t
			if d_max >= l and d_min <= h:
				d_min = max(d_min, l)
				d_max = min(d_max, h)
			else:
				bul = False
			now_t = t
	if bul:
		print('YES')
	else:
		print('NO')


import math
from sys import stdin, stdout

def main():
	T = int(stdin.readline())
	for _ in range(T):
		(n, m) = list(map(int, stdin.readline().split()))
		cust = []
		c = [m, m]
		for _ in range(n):
			(t, l, h) = list(map(int, stdin.readline().split()))
			cust.append((t, l, h))
		cust.sort(key=lambda tup: tup[0])
		fai = False
		last_time = 0
		for i in range(0, len(cust)):
			if c[0] <= cust[i][1] and c[1] >= cust[i][1] or (c[0] >= cust[i][1] and c[1] <= cust[i][2]) or (c[0] <= cust[i][2] and c[1] >= cust[i][2]):
				c = [max(c[0] - cust[i][0] + last_time, cust[i][1]), min(c[1] + cust[i][0] - last_time, cust[i][2])]
				last_time = cust[i][0]
				continue
			if c[0] < cust[i][1] and c[1] + cust[i][0] - last_time >= cust[i][1]:
				c = [max(c[0] - cust[i][0] + last_time, cust[i][1]), min(c[1] + cust[i][0] - last_time, cust[i][2])]
				last_time = cust[i][0]
				continue
			if c[1] > cust[i][2] and c[0] - cust[i][0] + last_time <= cust[i][2]:
				c = [max(c[0] - cust[i][0] + last_time, cust[i][1]), min(c[1] + cust[i][0] - last_time, cust[i][2])]
				last_time = cust[i][0]
				continue
			fai = True
			break
		if fai is True:
			stdout.write('NO\n')
		else:
			stdout.write('YES\n')
main()


def f(p, m):
	time = 0
	min_temp = max_temp = m
	for (t, l, h) in p:
		time_change = t - time
		max_temp += time_change
		min_temp -= time_change
		if min_temp > h or max_temp < l:
			return 'NO'
		max_temp = min(max_temp, h)
		min_temp = max(min_temp, l)
		time = t
	return 'YES'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		p.append([t, l, h])
	print(f(p, m))


q = int(input())
for _ in range(q):
	(n, m) = list(map(int, input().split()))
	customers = [[int(x) for x in input().split()] for _ in range(n)]
	(now_l, now_h) = (m, m)
	now = 0
	for (t, l, h) in customers:
		dt = t - now
		next_h = min(now_h + dt, h)
		next_l = max(now_l - dt, l)
		if not next_l <= next_h:
			ok = False
			break
		now = t
		(now_l, now_h) = (next_l, next_h)
	else:
		ok = True
	print('YES' if ok else 'NO')


import sys

def is_it_possible(initial_temp, customers):
	current_temp_scope = (initial_temp, initial_temp)
	current_time = 0
	for customer in customers:
		visit_time = customer[0]
		temp_low = customer[1]
		temp_high = customer[2]
		tmdiff = visit_time - current_time
		reachable_temp = (current_temp_scope[0] - tmdiff, current_temp_scope[1] + tmdiff)
		if reachable_temp[0] > temp_high or reachable_temp[1] < temp_low:
			return False
		current_temp_scope = (reachable_temp[0] if reachable_temp[0] > temp_low else temp_low, reachable_temp[1] if reachable_temp[1] < temp_high else temp_high)
		current_time = visit_time
	return True

def solve():
	line = sys.stdin.readline()
	left_case_number = int(line.strip())
	while left_case_number > 0:
		ns = sys.stdin.readline().split()
		left_customers = int(ns[0])
		initial_temp = int(ns[1])
		customers = []
		while left_customers > 0:
			customers.append([int(s) for s in sys.stdin.readline().split()])
			left_customers -= 1
		print('YES' if is_it_possible(initial_temp, customers) else 'NO')
		left_case_number -= 1
solve()


Q = int(input())

def after_time(t, curr):
	(a, b) = curr
	return (a - t, b + t)

def intersect(possible, target):
	(a, b) = possible
	(x, y) = target
	return (max(a, x), min(b, y))

def solve():
	(N, M) = [int(x) for x in input().split()]
	inp = []
	for _ in range(N):
		inp.append([int(x) for x in input().split()])
	inp.sort()
	T = (M, M)
	prev_time = 0
	possible = True
	for (Time, Lo, Hi) in inp:
		T = after_time(Time - prev_time, T)
		T = intersect(T, (Lo, Hi))
		prev_time = Time
		if T[-1] < T[0]:
			possible = False
			break
	print('YES' if possible else 'NO')
for _ in range(Q):
	solve()


q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	c = [[0, m, m]] + [list(map(int, input().split())) for i in range(n)]
	(xp, yp, zp) = c[0]
	flg = 1
	for i in range(1, n + 1):
		(x, y, z) = c[i]
		t = x - xp
		if yp - t <= z and zp + t >= y:
			pass
		else:
			flg = 0
			break
		(xp, yp, zp) = (x, max(yp - t, y), min(zp + t, z))
	if flg:
		print('YES')
	else:
		print('NO')


import sys

def input():
	return sys.stdin.readline().rstrip('\r\n')
q = int(input())
while q:
	q -= 1
	(n, m) = map(int, input().split())
	cus = [list(map(int, input().split())) for i in range(n)]

	def check():
		(cur, maxtemp, mintemp) = (0, m, m)
		for i in range(n):
			delta = cus[i][0] - cur
			cur = cus[i][0]
			maxtemp += delta
			mintemp -= delta
			maxtemp = min(maxtemp, cus[i][2])
			mintemp = max(mintemp, cus[i][1])
			if maxtemp < mintemp:
				return False
		return True
	if check():
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	upper = m
	lower = m
	ct = 0
	flag = 1
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		td = t - ct
		upper += td
		lower -= td
		if upper < l or lower > h:
			flag = 0
		upper = min(h, upper)
		lower = max(l, lower)
		ct = t
	print(['NO', 'YES'][flag])


def intersect(a, b, c, d):
	temp1 = max(a, c)
	temp2 = min(b, d)
	if temp2 < temp1:
		return None
	else:
		return [temp1, temp2]
for t in range(int(input())):
	(n, temp) = [int(i) for i in input().split()]
	time = 0
	pos = [temp, temp]
	f = 1
	for i in range(n):
		(in_time, l, h) = [int(i) for i in input().split()]
		if f:
			temp = in_time - time
			pos = [pos[0] - temp, pos[1] + temp]
			pos = intersect(l, h, pos[0], pos[1])
			time = in_time
			if pos is None:
				f = 0
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = list(map(int, input().split()))
	low = m
	high = m
	prev = 0
	f = 1
	for i in range(n):
		(tim, l, h) = list(map(int, input().split()))
		low -= tim - prev
		high += tim - prev
		if low > h or high < l:
			f = 0
		low = max(low, l)
		high = min(high, h)
		prev = tim
	if f:
		print('YES')
	else:
		print('NO')


q = int(input())
ans = ['YES'] * q
for x in range(q):
	(n, m) = [int(k) for k in input().split()]
	(t1, mn, mx) = (0, m, m)
	for y in range(n):
		(t, l, r) = [int(z) for z in input().split()]
		if l <= mx + (t - t1) and r >= mn - (t - t1):
			mx = min(r, mx + (t - t1))
			mn = max(l, mn - (t - t1))
			t1 = t
		else:
			ans[x] = 'NO'
for x in ans:
	print(x)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mn = mx = m
	pt = 0
	ans = 'YES'
	for _ in range(n):
		(t, l, r) = map(int, input().split())
		a = t - pt
		if mn - a > r or mx + a < l:
			ans = 'NO'
		mn = max(mn - a, l)
		mx = min(mx + a, r)
		pt = t
	print(ans)


t = int(input())
for i in range(0, t):
	(n, m) = map(int, input().split())
	tt = []
	ll = []
	hh = []
	for j in range(0, n):
		(ti, l, h) = map(int, input().split())
		tt.append(ti)
		ll.append(l)
		hh.append(h)
	max = m
	min = m
	c = 0
	p = 0
	for j in range(0, n):
		max = tt[j] - p + max
		min = min - (tt[j] - p)
		if min > hh[j] or max < ll[j]:
			c = 1
			break
		else:
			if min < ll[j]:
				min = ll[j]
			if max > hh[j]:
				max = hh[j]
		p = tt[j]
	if c == 1:
		print('NO')
	else:
		print('YES')


q = int(input())

def intersect(a, b):
	if a[1] < b[0] or a[0] > b[1]:
		return -1
	if a[0] >= b[0] and a[1] <= b[1]:
		return list(a)
	if a[0] <= b[0] and a[1] >= b[1]:
		return list(b)
	if a[0] < b[0]:
		return [b[0], a[1]]
	else:
		return [a[0], b[1]]

def solve(m, t):
	cur = [m, m]
	prev = 0
	for (x, edges) in t.items():
		cur[0] += prev - x
		cur[1] += x - prev
		prev = x
		cur = intersect(cur, edges)
		if cur == -1:
			return 'NO'
	return 'YES'
for _ in range(q):
	(n, m) = list(map(int, input().split()))
	t = {}
	flag = True
	for _ in range(n):
		(x, y, z) = list(map(int, input().split()))
		if flag:
			if x in t:
				tmp = intersect([y, z], t[x])
				if tmp == -1:
					flag = False
				else:
					t[x] = tmp
			else:
				t[x] = [y, z]
	if not flag:
		print('NO')
	else:
		print(solve(m, t))


def ol(l1, r1, l2, r2):
	if r1 < l2:
		return False
	if l1 > r2:
		return False
	return True
for tc in range(int(input())):
	(n, t0) = map(int, input().split(' '))
	a = []
	tu = t0
	td = t0
	for i in range(n):
		a.append(list(map(int, input().split(' '))))
	a.sort()
	flag = True
	ti = 0
	for i in range(len(a)):
		th = a[i][0] - ti
		tiu = tu + th
		tid = td - th
		if not ol(tid, tiu, a[i][1], a[i][2]):
			flag = False
			break
		tu = min(tiu, a[i][2])
		td = max(tid, a[i][1])
		ti = a[i][0]
	if flag:
		print('YES')
	else:
		print('NO')


def checker(n, m, t, l, h):
	(previous, flag) = (0, True)
	(mn, mx) = (m, m)
	for i in range(n):
		mx += t[i] - previous
		mn -= t[i] - previous
		if mx < l[i] or mn > h[i]:
			flag = False
			break
		mx = min(mx, h[i])
		mn = max(mn, l[i])
		previous = t[i]
	return 'YES' if flag else 'NO'
for _ in range(int(input())):
	(to, lo, ho) = (list(), list(), list())
	(N, M) = [int(i) for i in input().split()]
	for i in range(N):
		(T, L, H) = [int(i) for i in input().split()]
		to.append(T)
		lo.append(L)
		ho.append(H)
	print(checker(N, M, to, lo, ho))


import math, collections, sys
input = sys.stdin.readline

def case():
	(n, temp) = map(int, input().split())
	cr = [temp, temp]
	ct = 0
	z = []
	for _ in range(n):
		z.append(map(int, input().split()))
	for _ in range(n):
		(t, l, h) = z[_]
		cr = [cr[0] - (t - ct), cr[1] + (t - ct)]
		ct = t
		cr = [max(cr[0], l), min(cr[1], h)]
		if cr[0] > cr[1]:
			print('NO')
			return
	print('YES')
for _ in range(int(input())):
	case()


ttt = int(input())
for _ in range(ttt):
	(n, m) = map(int, input().split())
	nv = 0
	L = m
	R = m
	flag = False
	for __ in range(n):
		(t, l, h) = map(int, input().split())
		L -= t - nv
		R += t - nv
		if L > h or R < l:
			flag = True
		nv = t
		L = max(L, l)
		R = min(R, h)
	if flag:
		print('NO')
	else:
		print('YES')


from sys import stdin, exit
from typing import List, Tuple, Dict
tests = int(stdin.readline().rstrip())
for _ in range(tests):
	(customers, init_tmp) = [int(v) for v in stdin.readline().rstrip().split()]
	(min_temp, max_temp) = (init_tmp, init_tmp)
	failed = False
	last_arrival = 0
	for _ in range(customers):
		(arrival, lower, upper) = [int(v) for v in stdin.readline().rstrip().split()]
		time = arrival - last_arrival
		last_arrival = arrival
		if lower > max_temp + time or upper < min_temp - time:
			failed = True
		min_temp = max(min_temp - time, lower)
		max_temp = min(max_temp + time, upper)
	print(('YES', 'NO')[failed])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mn = mx = m
	prev_t = 0
	isPossible = True
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		d = t - prev_t
		if mn - d <= h and mx + d >= l:
			mn = max(mn - d, l)
			mx = min(mx + d, h)
		else:
			isPossible = False
		prev_t = t
	if isPossible:
		print('YES')
	else:
		print('NO')


def intersection(range_1, range_2):
	if range_1[0] > range_2[1] or range_1[1] < range_2[0]:
		return (False, ())
	else:
		return (True, (max(range_1[0], range_2[0]), min(range_1[1], range_2[1])))

def create_ranges(first_cust, second_cust):
	(t1, a1, b1) = first_cust
	(t2, a2, b2) = second_cust
	diff = t2 - t1
	return intersection((a2, b2), (a1 - diff, b1 + diff))
inp = lambda : map(int, input().split(' '))
t = int(input())
for _ in range(t):
	(n, init_t) = inp()
	customers = []
	customers.append([0, init_t, init_t])
	for i in range(n):
		customers.append(list(inp()))
	res = True
	for i in range(n):
		first_cust = customers[i]
		second_cust = customers[i + 1]
		(f, tup) = create_ranges(first_cust, second_cust)
		if not f:
			res = False
			break
		second_cust[1] = tup[0]
		second_cust[2] = tup[1]
	print('YES' if res else 'NO')


R = lambda : map(int, input().split())
(q,) = R()
for _ in [0] * q:
	(n, a) = R()
	b = a
	s = r = 0
	for _ in [0] * n:
		(t, l, h) = R()
		a = max(l, a - t + s)
		b = min(h, b + t - s)
		r |= a > b
		s = t
	print('YNEOS'[r::2])


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	visitors = []
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		visitors.append((t, l, h))
	minTemp = maxTemp = m
	t_prev = 0
	for (t, l, h) in visitors:
		minTemp -= t - t_prev
		maxTemp += t - t_prev
		if minTemp > h or maxTemp < l:
			print('NO')
			break
		minTemp = max(minTemp, l)
		maxTemp = min(maxTemp, h)
		t_prev = t
	else:
		print('YES')


for _ in range(int(input())):
	temp = input().split()
	n = int(temp[0])
	m = int(temp[1])
	prev = 0
	time = 0
	rl = m
	rh = m
	ans = True
	for i in range(n):
		temp = list(map(int, input().split()))
		time = temp[0] - prev
		prev = temp[0]
		if ans:
			rl -= time
			rh += time
			if temp[1] <= rh and temp[2] >= rl:
				rl = max(rl, temp[1])
				rh = min(rh, temp[2])
			else:
				ans = False
		else:
			continue
	if ans:
		print('YES')
	else:
		print('NO')


def check(n, m, t, l, h):
	mn = mx = m
	prev = 0
	for i in range(n):
		mn -= t[i] - prev
		mx += t[i] - prev
		if mn > h[i] or mx < l[i]:
			return 0
		mn = max(mn, l[i])
		mx = min(mx, h[i])
		prev = t[i]
	return 1

def main():
	q = int(input())
	while q:
		(n, m) = list(map(int, input().split()))
		t = []
		l = []
		h = []
		for i in range(n):
			(ti, li, hi) = list(map(int, input().split()))
			t.append(ti)
			l.append(li)
			h.append(hi)
		valid = check(n, m, t, l, h)
		if valid:
			print('YES')
		else:
			print('NO')
		q -= 1
main()


q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	t0 = 0
	t = []
	l = []
	h = []
	ans = 'YES'
	r = m
	for j in range(n):
		(t, l, h) = map(int, input().split())
		x = t - t0
		t0 = t
		m = max(l, m - x)
		r = min(h, r + x)
		if m > r:
			ans = 'NO'
	print(ans)


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(val)
(q,) = mp()
for _ in range(q):
	(n, m) = mp()
	low = high = m
	f = temp = 0
	for i in range(n):
		(t, l, h) = mp()
		low -= t - temp
		high += t - temp
		if l > high or h < low:
			f = 1
		else:
			low = max(l, low)
			high = min(h, high)
		temp = t
	if not f:
		cout('YES\n')
	else:
		cout('NO\n')


for _ in range(int(input())):
	(n, tinit) = map(int, input().split())
	np = False
	curl = tinit
	curh = tinit
	lasttime = 0
	for i in range(n):
		(ti, li, hi) = map(int, input().split())
		curl = curl - (ti - lasttime)
		curh = curh + (ti - lasttime)
		if not (curl > hi or curh < li):
			curh = min(curh, hi)
			curl = max(curl, li)
		else:
			np = True
		lasttime = ti
	if np:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout

def clamp(n, a, b):
	if n > a:
		return a
	elif n < b:
		return b
	return n
q = int(stdin.readline().strip())
for _ in range(q):
	(n, m) = map(int, stdin.readline().split())
	(lo, hi, cur) = (m, m, 0)
	possible = True
	for _ in range(n):
		(t, l, h) = map(int, stdin.readline().split())
		if possible:
			a = t - cur
			b = -a
			lo += clamp(l - lo, a, b)
			hi += clamp(h - hi, a, b)
			if lo > h or hi < l:
				possible = False
			(lo, hi) = (max(lo, l), min(hi, h))
			cur = t
	if possible:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	ans = 'YES'
	(n, m) = map(int, input().split())
	mh = ml = m
	tx = 0
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		if tx < t:
			mh += t - tx
			ml -= t - tx
			tx = t
		mh = min(mh, h)
		ml = max(ml, l)
		if mh < ml:
			ans = 'NO'
	print(ans)


t = int(input())
while t:
	(n, t2) = map(int, input().split())
	k = n
	(maxi, mini) = (t2, t2)
	ti = 0
	flag = True
	while n:
		(t1, l, r) = map(int, input().split())
		maxi += t1 - ti
		mini -= t1 - ti
		ti = t1
		if ~(maxi < l or mini > r) == -1:
			maxi = min(maxi, r)
			mini = max(mini, l)
		else:
			flag = False
		n -= 1
	if flag:
		print('YES')
	else:
		print('NO')
	t -= 1


tq = int(input())
for q in range(tq):
	(n, m) = map(int, input().split())
	left = m
	right = m
	p = 0
	t0 = 0
	for i in range(n):
		(t, l, r) = map(int, input().split())
		left = left - t + t0
		right = right + t - t0
		t0 = t
		if r < left or l > right:
			p = 1
		else:
			left = max(left, l)
			right = min(right, r)
	if not p:
		print('YES')
	else:
		print('NO')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, m) = ria()
		(up, down, tb) = (m, m, 0)
		ans = 1
		for i in range(n):
			(t, l, h) = ria()
			tx = t - tb
			up += tx
			down -= tx
			if down > h or up < l:
				ans = 0
			up = min(h, up)
			down = max(l, down)
			tb = t
		if ans == 0:
			print('NO')
		else:
			print('YES')
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


def solve():
	(n, m) = map(int, input().split())
	customers = dict()
	for i in range(n):
		(t, l, r) = map(int, input().split())
		if t in customers:
			customers[t] = [max(customers[t][0], l), min(customers[t][1], r)]
		else:
			customers[t] = [l, r]
	for t in customers:
		if customers[t][0] > customers[t][1]:
			return 'NO'
	arr = []
	for (key, value) in customers.items():
		arr.append([key, value[0], value[1]])
	arr.sort()
	(t_, l_, r_) = (0, m, m)
	for i in range(len(arr)):
		(t, l, r) = arr[i]
		c1 = r_ + (t - t_)
		c2 = l_ - (t - t_)
		r_ = min(r, c1)
		l_ = max(l, c2)
		if l_ > r_:
			return 'NO'
		t_ = t
	return 'YES'
for _ in range(int(input())):
	print(solve())


import sys
for q in range(int(input())):
	(n, m) = list(map(int, input().strip().split()))
	lastT = 0
	tl = m
	th = m
	ans = True
	for i in range(n):
		(t, l, h) = list(map(int, input().strip().split()))
		if ans:
			tim = t - lastT
			if tl - tim <= h and th + tim >= l:
				tl = max(tl - tim, l)
				th = min(th + tim, h)
			else:
				ans = False
			lastT = t
	print('YES' if ans else 'NO')


from collections import defaultdict

def problemA():
	t = int(input())
	for _ in range(t):
		(x, y, a, b) = map(int, input().split())
		if (y - x) % (a + b) == 0:
			print((y - x) // (a + b))
		else:
			print(-1)

def problemB():
	(n, m) = map(int, input().split())
	ss = set()
	res = []
	for i in range(n):
		s = input()
		rs = s[::-1]
		if rs in ss:
			res.append(s)
			ss.remove(rs)
		else:
			ss.add(s)
	long = ''
	for s in ss:
		if s == s[::-1] and len(s) > len(long):
			long = s
	res = ''.join(res)
	res = res + long + res[::-1]
	print(len(res))
	print(res)

def problemC():
	inf = 2 * 10 ** 9
	q = int(input())
	for _ in range(q):
		(n, m) = map(int, input().split())
		a = defaultdict(lambda : (-inf, inf))
		for _ in range(n):
			(t, l, h) = map(int, input().split())
			(pl, ph) = a[t]
			a[t] = (max(l, pl), min(h, ph))
		pt = 0
		(pl, ph) = (m, m)
		res = 'YES'
		for t in sorted(a.keys()):
			(l, h) = a[t]
			delta = t - pt
			cl = pl - delta
			ch = ph + delta
			pl = max(l, cl)
			ph = min(h, ch)
			if pl > ph:
				res = 'NO'
				break
			pt = t
		print(res)

def problemG():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = map(int, input().split())
		res = 0
		print(a)
problemC()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lm = hm = m
	pt = 0
	ans = 'YES'
	for i in range(n):
		(t, l, h) = map(int, input().split())
		lm -= t - pt
		hm += t - pt
		pt = t
		hm = min(h, hm)
		lm = max(l, lm)
		if hm < lm:
			ans = 'NO'
	print(ans)


f = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, m) = f()
	t = [0] * (n + 1)
	l = [0] * (n + 1)
	u = [0] * (n + 1)
	flag = 1
	l[0] = u[0] = pl = pu = m
	pt = 0
	for i in range(1, n + 1):
		(t[i], l[i], u[i]) = f()
	for i in range(1, n + 1):
		if l[i] > pu and abs(l[i] - pu) > t[i] - pt:
			flag = 0
			break
		if u[i] < pl and abs(u[i] - pl) > t[i] - pt:
			flag = 0
			break
		pl = max(pl - t[i] + pt, l[i])
		pu = min(pu + t[i] - pt, u[i])
		pt = t[i]
	print('YES') if flag else print('NO')


def read_ints():
	return [int(i) for i in input().strip().split()]

def solve():
	pass

def intersection(left, right, mn, mx):
	if right < mn or left > mx:
		return None
	else:
		return [max(left, mn), min(right, mx)]

def main():
	t = int(input())
	for _ in range(t):
		(n, start) = read_ints()
		arr = []
		for _ in range(n):
			arr.append(read_ints())
		arr = sorted(arr, key=lambda x: x[0])
		left = start
		right = start
		ans = True
		current_time = 0
		for i in range(n):
			(time, mn, mx) = arr[i]
			diff = time - current_time
			current_time = time
			left = left - diff
			right = right + diff
			tmp = intersection(left, right, mn, mx)
			if tmp == None:
				ans = False
				break
			else:
				(left, right) = tmp
		if ans:
			print('YES')
		else:
			print('NO')
main()


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	curt = 0
	(lo, hi) = (m, m)
	bad = 0
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		if bad:
			continue
		lo -= t - curt
		hi += t - curt
		curt = t
		if l > hi or h < lo:
			bad = 1
		lo = max(lo, l)
		hi = min(hi, h)
	print('NO' if bad else 'YES')


def judge(li, n, m):
	low = m
	high = m
	for i in range(1, n + 1):
		time = li[i][0] - li[i - 1][0]
		low = max(low - time, li[i][1])
		high = min(high + time, li[i][2])
		if low > high:
			return False
	return True

def solve():
	case = int(input())
	for _t in range(case):
		(n, m) = map(int, input().split())
		li = []
		li.append([0, m, m])
		for i in range(1, n + 1):
			(t, l, h) = map(int, input().split())
			li.append([t, l, h])
		if judge(li, n, m):
			print('YES')
		else:
			print('NO')
solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tp = []
	for i in range(n):
		(t, l, r) = map(int, input().split())
		tp.append((t, l, r))
	tp.sort(key=lambda x: x[0])
	(mn, mx) = (m, m)
	ch = 1
	tm = 0
	for i in range(n):
		(t, l, r) = (tp[i][0], tp[i][1], tp[i][2])
		p = mn - (t - tm)
		q = mx + (t - tm)
		if p > r:
			ch = 0
			break
		elif q < l:
			ch = 0
			break
		elif q >= r:
			mx = r
			if p <= l:
				mn = l
			else:
				mn = p
		elif q <= r:
			mx = q
			if p <= l:
				mn = l
			else:
				mn = p
		tm = t
	if ch == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	temp = []
	for i in range(n):
		temp.append(list(map(int, input().split())))
	mini = m
	maxi = m
	prev_time = 0
	f = 1
	for i in range(n):
		diff = temp[i][0] - prev_time
		if maxi + diff < temp[i][1] or mini - diff > temp[i][2]:
			f = 0
			break
		if diff + maxi >= temp[i][2]:
			maxi = temp[i][2]
		else:
			maxi += diff
		if mini - diff <= temp[i][1]:
			mini = temp[i][1]
		else:
			mini -= diff
		prev_time = temp[i][0]
	if f == 0:
		print('NO')
	else:
		print('YES')


def solve_problem(cus_num, init_temp, params):
	time = 0
	min_temp = init_temp
	max_temp = init_temp
	for (t, l, h) in params:
		time_change = t - time
		min_temp -= time_change
		max_temp += time_change
		if min_temp > h or max_temp < l:
			return 'NO'
		min_temp = max(min_temp, l)
		max_temp = min(max_temp, h)
		time = t
	return 'YES'

def main():
	problem_number = input()
	for i in range(int(problem_number)):
		(cus_num, init_temp) = input().split()
		params = []
		for i in range(int(cus_num)):
			(t, l, h) = input().split()
			params.append([int(t), int(l), int(h)])
		print(solve_problem(int(cus_num), int(init_temp), params))
main()


def ranger(time, low, up):
	global iniTime, tempRange
	diff = time - iniTime
	minRange = tempRange[0] - diff
	maxRange = tempRange[-1] + diff
	if maxRange < low or minRange > up:
		return False
	iniTime = time
	tempRange = [max(minRange, low), min(maxRange, up)]
	return True
for _ in range(int(input())):
	(n, currTemp) = map(int, input().split())
	tempRange = [currTemp, currTemp]
	iniTime = 0
	chk = True
	for i in range(0, n):
		(time, low, up) = map(int, input().split())
		if not ranger(time, low, up):
			chk = False
	if chk:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline

def getAns(n, m):
	c = sorted([list(map(int, input().split())) for i in range(n)])
	(l, h, t) = (m, m, 0)
	for i in range(n):
		if c[i][0] - t + h < c[i][1] or l - (c[i][0] - t) > c[i][2]:
			return 'NO'
		(l, h, t) = (max(c[i][1], l - (c[i][0] - t)), min(c[i][2], h + (c[i][0] - t)), c[i][0])
	return 'YES'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	print(getAns(n, m))


I = lambda : map(int, input().rstrip().split())
for _ in range(int(input())):
	(n, m) = I()
	maxm = m
	minm = m
	flag = 1
	t2 = 0
	for i in range(n):
		(t1, l, r) = I()
		t = t1 - t2
		t2 = t1
		if l <= maxm + t and r >= minm - t:
			maxm = min(maxm + t, r)
			minm = max(l, minm - t)
		else:
			flag = 0
	if flag:
		print('YES')
	else:
		print('NO')


Q = int(input())
for q in range(Q):
	(n, m) = map(int, input().split())
	persons = []
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		persons.append((t, l, h))
	persons = sorted(persons)
	low = m
	high = m
	time = 0
	possible = True
	for (t, l, h) in persons:
		low -= t - time
		high += t - time
		time = t
		if h < low or l > high:
			possible = False
			break
		low = max([l, low])
		high = min([h, high])
	if possible:
		print('YES')
	else:
		print('NO')


def is_ok_with_all_customers():
	(number_of_customers, current_temperature) = tuple(map(int, input().split()))
	customers_data = {}
	for i in range(number_of_customers):
		(t, l, h) = tuple(map(int, input().split()))
		if t in customers_data:
			customers_data[t] = (max(l, customers_data[t][0]), min(h, customers_data[t][1]))
		else:
			customers_data[t] = (l, h)
	current_time = 0
	current_temperature_range = (current_temperature, current_temperature)
	for (t, v) in customers_data.items():
		time_to_prepare = t - current_time
		max_possible_temperate_for_guests = current_temperature_range[1] + time_to_prepare
		min_possible_temperature_for_guests = current_temperature_range[0] - time_to_prepare
		if max_possible_temperate_for_guests < v[0] or v[1] < min_possible_temperature_for_guests:
			return 'NO'
		current_temperature_range = (max(min_possible_temperature_for_guests, v[0]), min(max_possible_temperate_for_guests, v[1]))
		if current_temperature_range[0] > current_temperature_range[1]:
			return 'NO'
		current_time = t
	return 'YES'
test_cases = int(input())
for _ in range(test_cases):
	print(is_ok_with_all_customers())


input = __import__('sys').stdin.readline
test_cases = int(input())
output = []
for _ in range(test_cases):
	(number_of_customers, temperature) = map(int, input().split())
	previous_time = 0
	lowest_temp_reachable = highest_temp_reachable = temperature
	customers = []
	for i in range(number_of_customers):
		customers.append(input())
	for customer in customers:
		(time, low_temp, high_temp) = map(int, customer.split())
		delta_time = time - previous_time
		delta_temp = delta_time
		new_lowest_temp = lowest_temp_reachable - delta_temp
		new_highest_temp = highest_temp_reachable + delta_temp
		new_lowest_temp = max(new_lowest_temp, low_temp)
		new_highest_temp = min(new_highest_temp, high_temp)
		if new_lowest_temp > new_highest_temp:
			output.append('NO')
			break
		lowest_temp_reachable = new_lowest_temp
		highest_temp_reachable = new_highest_temp
		previous_time = time
	else:
		output.append('YES')
print('\n'.join(output))


T = int(input())
while T > 0:
	(n, m) = map(int, input().split())
	span = [m, m]
	prev_time = 0
	sche = True
	for i in range(n):
		(t, l, h) = map(int, input().split())
		span[0] -= t - prev_time
		span[1] += t - prev_time
		prev_time = t
		span[1] = min(span[1], h)
		span[0] = max(span[0], l)
		if span[0] > span[1]:
			sche = False
	if sche is False:
		print('NO')
	else:
		print('YES')
	T -= 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(N, M) = map(int, input().split())
	(ts, ls, hs) = ([0], [M], [M])
	for _ in range(N):
		(t, l, h) = map(int, input().split())
		ts.append(t)
		ls.append(l)
		hs.append(h)
	(t, l, h) = (ts.pop(), ls.pop(), hs.pop())
	flag = True
	st = [l, h]
	while ts:
		nt = ts.pop()
		nst = [ls.pop(), hs.pop()]
		st = [st[0] - (t - nt), st[1] + (t - nt)]
		t = nt
		st = [max(st[0], nst[0]), min(st[1], nst[1])]
		if st[0] > st[1]:
			flag = False
			break
	if flag:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t0 = 0
	a = 'YES'
	r = m
	for i in range(n):
		(t, l, h) = map(int, input().split())
		t1 = t - t0
		t0 = t
		m = max(l, m - t1)
		r = min(h, r + t1)
		if m > r:
			a = 'NO'
	print(a)


from sys import stdin, stdout
from collections import deque
T = int(stdin.readline())
for i in range(T):
	(n, m) = map(int, stdin.readline().split())
	l = []
	for i in range(n):
		(t, lll, h) = map(int, stdin.readline().split())
		l.append((t, lll, h))
	l2 = [(0, m, m)]
	ci = 0
	while ci < n:
		ct = l[ci][0]
		tl = l[ci][1]
		tu = l[ci][2]
		ci += 1
		l2.append((ct, tl, tu))
	n = len(l2)
	x = -10000000000
	y = -1 * x
	ans = 'YES'
	for i in range(n - 1, -1, -1):
		t = l2[i][0]
		lll = l2[i][1]
		h = l2[i][2]
		if y < lll or x > h:
			ans = 'NO'
			break
		lll = max(lll, x)
		h = min(h, y)
		if i > 0:
			tm = l2[i - 1][0]
			x = lll - (t - tm)
			y = h + (t - tm)
	print(ans)


from collections import namedtuple
delta = namedtuple('delta', ['high', 'low'])

def _make_next_possible_delta(current_delta, time):
	return delta(current_delta.high + time, current_delta.low - time)

def _intersect_deltas(delta_one, delta_two):
	return delta(min(delta_one.high, delta_two.high), max(delta_one.low, delta_two.low))
task_number = int(input())
for _ in range(task_number):
	(n, m) = map(int, input().split())
	answer = True
	current_delta = delta(m, m)
	previous_time = 0
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		time_diff = t - previous_time
		previous_time = t
		user_delta = delta(h, l)
		next_possible_delta = _make_next_possible_delta(current_delta, time_diff)
		current_delta = _intersect_deltas(next_possible_delta, user_delta)
		if current_delta.high < current_delta.low:
			answer = False
	if answer:
		print('YES')
	else:
		print('NO')


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, m) = [int(i) for i in stdin.readline().split(' ')]
	l = []
	for i in range(n):
		a = [int(i) for i in stdin.readline().split(' ')]
		l.append(a)
	prevl = m
	prevr = m
	time = 0
	flag = False
	for i in l:
		time = i[0] - time
		lr = prevl - time
		hr = prevr + time
		(a, b) = (max(i[1], lr), min(i[2], hr))
		if a <= b:
			prevl = a
			prevr = b
			time = i[0]
		else:
			flag = True
			print('NO')
			break
	if flag == False:
		print('YES')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(n, m) = inp()
	arr = []
	for i in range(n):
		arr.append(list(inp()))
	(mn, mx) = (m, m)
	flag = True
	prev = 0
	for i in range(n):
		mx += arr[i][0] - prev
		mn -= arr[i][0] - prev
		if mx < arr[i][1] or mn > arr[i][2]:
			flag = False
			break
		mx = min(mx, arr[i][2])
		mn = max(mn, arr[i][1])
		prev = arr[i][0]
	if flag:
		ans = 'YES'
	else:
		ans = 'NO'
	out(ans)


from collections import defaultdict
q = int(input())
while q:
	q -= 1
	(n, m) = map(int, input().split())
	c = []
	d = defaultdict(list)
	for i in range(n):
		c.append(list(map(int, input().split())))
	for i in range(n):
		if len(d[c[i][0]]) == 0:
			d[c[i][0]].append([c[i][1], c[i][2]])
		else:
			d[c[i][0]][0][0] = max(c[i][1], d[c[i][0]][0][0])
			d[c[i][0]][0][1] = min(c[i][2], d[c[i][0]][0][1])
	cur = 0
	l = m
	h = m
	first = True
	for (k, v) in sorted(d.items(), key=lambda x: x[0]):
		l -= k - cur
		h += k - cur
		cur = k
		if max(l, v[0][0]) <= min(h, v[0][1]):
			l = max(l, v[0][0])
			h = min(h, v[0][1])
		else:
			print('NO')
			first = False
			break
	if first:
		print('YES')


local = False
if local:
	file = open('C.txt', 'r')

def readInput():
	if local:
		return file.readline()
	else:
		return input()

def solve(n, temp, guests):
	last_range = [temp, temp]
	last_time = 0
	for g in guests:
		(ti, li, hi) = g
		adjrange = ti - last_time
		lowest_prev = li - adjrange
		highest_prev = hi + adjrange
		if lowest_prev > last_range[1] or highest_prev < last_range[0]:
			return False
		last_range = [max(last_range[0] - adjrange, li), min(last_range[1] + adjrange, hi)]
		last_time = ti
	return True
q = int(readInput())
for i in range(q):
	nm = readInput().split()
	(n, m) = (int(nm[0]), int(nm[1]))
	guests = []
	for j in range(n):
		tlh = [int(n) for n in readInput().split()]
		guests.append(tlh)
	if solve(n, m, guests):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	users = [list(map(int, input().split())) for _ in range(n)]
	good = True
	time = 0
	t = [t, t]
	for i in range(len(users)):
		delta = users[i][0] - time
		if t[0] - delta > users[i][2] or t[1] + delta < users[i][1]:
			print('NO')
			good = False
			break
		time = users[i][0]
		t[0] = max(t[0] - delta, users[i][1])
		t[1] = min(t[1] + delta, users[i][2])
	if good:
		print('YES')


import sys
sys.setrecursionlimit(10 ** 6)
for _ in range(int(input())):

	def rec(i, mini, maxi):
		if i >= n:
			return True
		if i == 0:
			curr_mini = max(arr[i][1], mini - arr[i][0])
			curr_max = min(arr[i][2], maxi + arr[i][0])
			if arr[i][1] <= curr_mini <= curr_max <= arr[i][2]:
				return rec(i + 1, curr_mini, curr_max)
			return False
		else:
			curr_mini = max(arr[i][1], mini - (arr[i][0] - arr[i - 1][0]))
			curr_max = min(arr[i][2], maxi + (arr[i][0] - arr[i - 1][0]))
			if arr[i][1] <= curr_mini <= curr_max <= arr[i][2]:
				return rec(i + 1, curr_mini, curr_max)
			return False
	(n, initial) = list(map(int, sys.stdin.readline().split()))
	arr = []
	for i in range(n):
		arr.append(list(map(int, sys.stdin.readline().split())))
	if rec(0, initial, initial):
		print('YES')
	else:
		print('NO')


import sys
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
for i in range(int(input())):
	(n, m) = read()
	last_t = 0
	(maxx, minn) = (m, m)
	poss = True
	for i in range(n):
		(t, l, h) = read()
		if poss == False:
			continue
		del_t = t - last_t
		maxx = maxx + del_t
		minn = minn - del_t
		if maxx < l or minn > h:
			poss = False
		last_t = t
		maxx = min(h, maxx)
		minn = max(l, minn)
	print(('NO', 'YES')[poss])


t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	arr = []
	for i in range(n):
		arr.append([int(i) for i in input().split()])
	prev = flag = 0
	m_l = m_h = m
	for i in range(len(arr)):
		(t1, l1, h1) = arr[i]
		time = t1 - prev
		if l1 >= m_h and h1 > m_h:
			diff_l = l1 - m_h
			diff_h = h1 - m_h
			if diff_h <= time or diff_l <= time:
				m_l = max(m_l - time, l1)
				m_h = min(m_h + time, h1)
			else:
				flag = 1
				break
		elif h1 <= m_l and l1 < m_l:
			diff_l = m_l - l1
			diff_h = m_l - h1
			if diff_h <= time or diff_l <= time:
				m_l = max(m_l - time, l1)
				m_h = min(m_h + time, h1)
			else:
				flag = 1
				break
		else:
			m_l = max(m_l - time, l1)
			m_h = min(m_h + time, h1)
		prev = t1
	if flag == 1:
		print('NO')
	else:
		print('YES')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	data = [list(map(int, input().split())) for _ in range(n)][::-1]
	low = data[0][1]
	high = data[0][2]
	b = True
	for i in range(1, n):
		time = data[i - 1][0] - data[i][0]
		low -= time
		high += time
		if high < data[i][1] or low > data[i][2]:
			b = False
			break
		high = min(high, data[i][2])
		low = max(low, data[i][1])
	low -= data[-1][0]
	high += data[-1][0]
	if m < low or high < m:
		b = False
	print('YES' if b else 'NO')


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
input = sys.stdin.readline
res = []
for _ in range(ii()):
	(n, start) = mi()
	b = t = start
	prev = 0
	good = True
	for _ in range(n):
		(time, l, h) = mi()
		if not good:
			continue
		(k, prev) = (time - prev, time)
		top = min(t + k, h)
		bot = max(b - k, l)
		if top < l or bot > h:
			good = False
		(b, t) = (bot, top)
	print('YES' if good else 'NO')
prr(res, '\n')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(mint, maxt) = (m, m)
	ct = 0
	ans = 'YES'
	for i in range(n):
		(t, l, r) = map(int, input().split())
		mint -= t - ct
		maxt += t - ct
		ct = t
		maxt = min(r, maxt)
		mint = max(l, mint)
		if maxt < mint:
			ans = 'NO'
	print(ans)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right

def solve():
	(n, m) = map(int, stdin.readline().split())
	(L, R, T) = (m, m, 0)
	retval = True
	for _ in range(n):
		(t, l, r) = map(int, stdin.readline().split())
		L -= t - T
		R += t - T
		if l > R:
			retval = False
		if r < L:
			retval = False
		if l > L:
			L = l
		if r < R:
			R = r
		T = t
	return retval
cases = int(input())
for _ in range(cases):
	if solve():
		print('YES')
	else:
		print('NO')


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
q = int(readline())
for _ in range(q):
	(n, m) = map(int, readline().split())
	flag = 1
	(now_higt, now_low) = (m, m)
	now_t = 0
	for i in range(n):
		(t, l, h) = map(int, readline().split())
		t -= now_t
		now_t += t
		(next_low, next_higt) = (now_low - t, now_higt + t)
		subflag = 0
		if l > next_higt and l > next_low or (h < next_higt and h < next_low):
			flag = 0
		if next_low <= l:
			now_low = l
		else:
			now_low = next_low
		if next_higt >= h:
			now_higt = h
		else:
			now_higt = next_higt
	if flag:
		print('YES')
	else:
		print('NO')


import sys
INF = 10 ** 18
MOD = 10 ** 9 + 7

def input():
	return sys.stdin.readline().rstrip()

def main():
	q = int(input())
	for _ in range(q):
		(n, m) = map(int, input().split())
		(time, l, h) = ([0] * (n + 1), [0] * n, [0] * n)
		for i in range(n):
			(time[i + 1], l[i], h[i]) = map(int, input().split())
		t = [0] * n
		for i in range(n):
			t[i] = time[i + 1] - time[i]
		(L, H) = (m, m)
		for i in range(n):
			L -= t[i]
			H += t[i]
			if L <= l[i] <= H or L <= h[i] <= H or (l[i] <= L and h[i] >= H):
				L = max(L, l[i])
				H = min(H, h[i])
			else:
				print('NO')
				break
		else:
			print('YES')
main()


import math
from decimal import *
import random
mod = int(1000000000.0) + 7
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ok = True
	(rl, rr) = (int(m), int(m))
	ltime = 0
	for i in range(n):
		(t, l, r) = map(int, input().split())
		add = int(t - ltime)
		ltime = int(t)
		if rl - add > r or rr + add < l:
			ok = False
		rl = max(l, rl - add)
		rr = min(r, rr + add)
	if ok:
		print('YES')
	else:
		print('NO')


def solve():
	(n, m) = [int(s) for s in input().strip().split()]
	C = []
	for _ in range(n):
		C.append([int(s) for s in input().strip().split()])
	time = 0
	lo = hi = m
	for (t, l, h) in C:
		dt = t - time
		(lo, hi) = (max(lo - dt, l), min(hi + dt, h))
		if lo > hi:
			print('NO')
			return
		time = t
	print('YES')

def main():
	for _ in range(int(input().strip())):
		solve()
main()


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	lo = m
	hi = m
	t0 = 0
	ans = True
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		dt = t - t0
		lo = lo - dt
		hi = hi + dt
		if l > hi or h < lo:
			ans = False
		lo = max(lo, l)
		hi = min(hi, h)
		t0 = t
	if ans:
		print('YES')
	else:
		print('NO')


q = int(input())
while q > 0:
	s = input().split()
	n = int(s[0])
	m = int(s[1])
	lt = 0
	ls = m
	hs = m
	ok = 1
	while n > 0:
		s1 = input().split()
		ti = int(s1[0])
		li = int(s1[1])
		hi = int(s1[2])
		ls = ls - (ti - lt)
		hs = hs + (ti - lt)
		if ls > hi or hs < li:
			ok = 0
		ls = max(ls, li)
		hs = min(hs, hi)
		lt = ti
		n = n - 1
	if ok == 1:
		print('YES')
	else:
		print('NO')
	q = q - 1


from bisect import *
from math import *
q = int(input())
for i in range(q):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	arr = []
	for j in range(n):
		(t, l, h) = input().split()
		t = int(t)
		l = int(l)
		h = int(h)
		arr.append((t, l, h))
	arr.sort()

	def check(t1, t2):
		if t1[1] < t2[0] or t2[1] < t1[0]:
			return False
		else:
			return True

	def intersect(t1, t2):
		if check(t1, t2):
			return (max(t1[0], t2[0]), min(t1[1], t2[1]))
	flag = True
	t = arr[0][0]
	ran = (m - arr[0][0], m + arr[0][0])
	if check(ran, (arr[0][1], arr[0][2])):
		ran = intersect(ran, (arr[0][1], arr[0][2]))
		for j in range(1, n):
			ran = (ran[0] - (arr[j][0] - arr[j - 1][0]), ran[1] + (arr[j][0] - arr[j - 1][0]))
			if check(ran, (arr[j][1], arr[j][2])):
				ran = intersect(ran, (arr[j][1], arr[j][2]))
			else:
				flag = False
				break
	else:
		flag = False
	if flag == True:
		print('YES')
	else:
		print('NO')


def per(a, b, c, d):
	return [max(a, c), min(b, d)]
q = int(input())
for l in range(q):
	(n, m) = map(int, input().split())
	a = m
	b = m
	o = 0
	tm = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		(a, b) = per(a - (t - tm), b + (t - tm), l, h)
		tm = t
		if b < a:
			o = 1
		if a < l and b < l or (a > h and b > h):
			o = 1
	if o == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(tl, ll, rl) = ([], [], [])
	for i in range(n):
		(t, l, r) = map(int, input().split())
		tl.append(t)
		ll.append(l)
		rl.append(r)
	flag = 0
	ct = 0
	(mi, mx) = (m, m)
	for i in range(n):
		mx += tl[i] - ct
		mi -= tl[i] - ct
		if mx < ll[i] or mi > rl[i]:
			flag = 1
			break
		mx = min(rl[i], mx)
		mi = max(ll[i], mi)
		ct = tl[i]
	if flag == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(customers, start_with) = [int(x) for x in input().split()]
	(at_time, lower, higher) = ([], [], [])
	for i in range(customers):
		(a, l, h) = [int(x) for x in input().split()]
		at_time.append(a)
		lower.append(l)
		higher.append(h)
	last_temp = 0
	mins = start_with
	maxs = start_with
	can_do = True
	for i in range(customers):
		maxs += at_time[i] - last_temp
		mins -= at_time[i] - last_temp
		if maxs < lower[i] or mins > higher[i]:
			can_do = False
			break
		maxs = min(maxs, higher[i])
		mins = max(mins, lower[i])
		last_temp = at_time[i]
	print('YES' if can_do else 'NO')


import os
import operator
import sys
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		pairs = []
		for i in range(n):
			(t, l, u) = map(int, input().split())
			pairs.append((t, l, u))
		lower = 10 ** 9
		upper = -1
		counter = 0
		for i in range(n):
			if i == 0:
				t = pairs[i][0]
				l = pairs[i][1]
				u = pairs[i][2]
				lower = max(m - t, l)
				upper = min(m + t, u)
				if upper < l or lower > u:
					counter = 1
					break
				continue
			t = pairs[i][0]
			l = pairs[i][1]
			u = pairs[i][2]
			diff = t - pairs[i - 1][0]
			lower = max(lower - diff, l)
			upper = min(upper + diff, u)
			if upper < l or lower > u:
				counter = 1
				break
		if counter:
			print('NO')
		else:
			print('YES')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	f = True
	canLow = m
	canHigh = m
	curTime = 0
	dat = []
	for _ in range(n):
		(visitTime, needLow, needHigh) = map(int, input().split())
		dat.append((visitTime, needLow, needHigh))
	for i in range(n):
		(visitTime, needLow, needHigh) = dat[i]
		deltaTime = visitTime - curTime
		canLow -= deltaTime
		canHigh += deltaTime
		if needHigh < canLow or canHigh < needLow:
			f = False
			break
		curTime = visitTime
		if needLow > canLow:
			canLow = needLow
		if needHigh < canHigh:
			canHigh = needHigh
	if f:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	(n, m) = map(int, input().split())
	a = b = m
	m = 0
	fl = 1
	for tccc in range(n):
		(t, l, h) = map(int, input().split())
		a -= t - m
		b += t - m
		m = t
		if a < l:
			a = l
		if b > h:
			b = h
		if a > b:
			fl = 0
	print('YES') if fl else print('NO')


def check(a1, b1, a2, b2):
	if b1 < a2 or a1 > b2:
		return False
	return True
for _ in range(int(input())):
	(n, t) = [int(x) for x in input().split(' ')]
	arr = []
	(t1, t2, s) = (t, t, 0)
	f = True
	for z in range(n):
		(c, a, b) = [int(x) for x in input().split(' ')]
		mov = c - s
		s = c
		(t1, t2) = (t1 - mov, t2 + mov)
		if f and check(t1, t2, a, b):
			t1 = max(a, t1)
			t2 = min(b, t2)
		else:
			f = False
	if f:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def main():
	q = int(rl())
	for _ in range(q):
		(n, init) = (int(x) for x in rll())
		customers = []
		for _ in range(n):
			customers.append([int(x) for x in rll()])
		failed = False
		(last_low, last_high) = (init, init)
		last_t = 0
		for (t, L, H) in customers:
			dt = t - last_t
			low = last_low - dt
			high = last_high + dt
			if low > H:
				stdout.write('NO\n')
				failed = True
				break
			if high < L:
				stdout.write('NO\n')
				failed = True
				break
			(last_low, last_high) = (max(L, low), min(H, high))
			last_t = t
		if not failed:
			stdout.write('YES\n')
	stdout.close()
main()


import sys
input = sys.stdin.readline
inf = int(10000000000.0)
t_ = int(input())
while t_:
	t_ -= 1
	(n, x) = map(int, input().split())
	(mn, mx) = (x, x)
	g = 0
	store = [tuple(map(int, input().split())) for _ in range(n)]
	p = 0
	for i in store:
		(t, l, h) = i
		mn -= t - p
		mx += t - p
		if mx < l or mn > h:
			g = 1
			break
		else:
			mx = min(mx, h)
			mn = max(mn, l)
			p = t
	if g:
		print('NO')
	else:
		print('YES')


cases = int(input())
for q in range(cases):
	(n, m) = list(map(int, input().split()))
	tlh = [[0, m, m]]
	for i in range(n):
		(ti, li, hi) = list(map(int, input().split()))
		tlh.append([ti, li, hi])
	tlh = sorted(tlh)
	for i in range(1, n + 1):
		(ti, li, hi) = tlh[i]
		(pti, pli, phi) = tlh[i - 1]
		delta = ti - pti
		low = pli - delta
		high = phi + delta
		f = 0
		if low <= li and high >= hi:
			pass
		elif low >= li and high <= hi:
			li = low
			hi = high
		elif high >= li and high <= hi:
			hi = high
		elif low >= li and low <= hi:
			li = low
		else:
			f = 1
		if f == 1:
			break
		else:
			tlh[i] = [ti, li, hi]
	if f == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 'YES'
	lower = m
	higest = m
	prev = 0
	for i in range(n):
		(t, l, r) = map(int, input().split())
		if flag == 'YES':
			z = t
			t = t - prev
			prev = z
			x = lower - t
			y = higest + t
			if x <= r and l <= y:
				lower = max(x, l)
				higest = min(y, r)
			else:
				flag = 'NO'
	print(flag)


for _ in range(int(input())):
	(n, m) = [int(__) for __ in input().split()]
	data = []
	for i in range(n):
		data.append([int(__) for __ in input().split()])
	(l_bound, u_bound, time) = (m, m, 0)
	for i in data:
		l_bound -= i[0] - time
		u_bound += i[0] - time
		time = i[0]
		if i[1] in range(l_bound, u_bound + 1):
			l_bound = i[1]
		if i[2] in range(l_bound, u_bound):
			u_bound = i[2]
		if i[2] < l_bound or i[1] > u_bound:
			print('NO')
			break
	else:
		print('YES')


def inter(a, b, x, y):
	if b < x or y < a:
		return -1
	else:
		return (max(a, x), min(b, y))
tests = int(input())
for _ in range(tests):
	jj = input()
	(n, ini) = map(int, jj.strip().split())
	(ini_l, ini_h) = (ini, ini)
	init = 0
	flag = False
	for i in range(n):
		(t, l, h) = map(int, input().split())
		dt = t - init
		ini_l -= dt
		ini_h += dt
		if not flag:
			inte = inter(l, h, ini_l, ini_h)
			if inte == -1:
				flag = True
			else:
				(ini_l, ini_h) = inte
			init = t
	if not flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	last = 0
	ran = (m, m)
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if ran[1] + t - last < l or ran[0] - t + last > h:
			print('NO')
			for j in range(n - i - 1):
				a = input()
			break
		elif ran[1] < l:
			ran = (l, min(h, ran[1] + t - last))
		elif ran[0] > h:
			ran = (max(l, ran[0] - t + last), h)
		else:
			ran = (max(l, ran[0] - t + last), min(h, ran[1] + t - last))
		last = t
	else:
		print('YES')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	to = 0
	lo = m
	ro = m
	f = True
	for i in range(n):
		(t, l, r) = map(int, input().split())
		lo -= t - to
		ro += t - to
		if lo <= l <= ro or lo <= r <= ro or l <= lo <= r or (l <= ro <= r):
			(to, lo, ro) = (t, max(l, lo), min(r, ro))
		else:
			f = False
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = b = m
	m = 0
	ans = 'YES'
	for nmn in range(n):
		(t, ll, hh) = map(int, input().split())
		a -= t - m
		b += t - m
		m = t
		if a < ll:
			a = ll
		if b > hh:
			b = hh
		if a > b:
			ans = 'NO'
	print(ans)


j = int(input())
for j0 in range(j):
	(n, l0) = map(int, input().split())
	h0 = l0
	t0 = 0
	temp = True
	for n0 in range(n):
		(t, l, h) = map(int, input().split())
		l1 = l0 - (t - t0)
		h1 = h0 + (t - t0)
		if l1 <= l <= h1 <= h:
			l0 = l
			h0 = h1
		elif l <= l1 <= h <= h1:
			l0 = l1
			h0 = h
		elif l <= l1 <= h1 <= h:
			l0 = l1
			h0 = h1
		elif l1 <= l <= h <= h1:
			l0 = l
			h0 = h
		else:
			temp = False
		t0 = t
	if temp == True:
		print('Yes')
	else:
		print('No')


q = int(input())

def inter(a, b):
	return (max(a[0], b[0]), min(a[1], b[1]))
for i in range(q):
	(n, m) = map(int, input().split())
	rang = (m, m)
	last = 0
	good = True
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if not good:
			continue
		minutes = t - last
		last = t
		rang = (rang[0] - minutes, rang[1] + minutes)
		comp = inter((l, h), rang)
		if comp[0] > comp[1]:
			good = False
		rang = comp
	if good:
		print('YES')
	else:
		print('NO')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		l.append(list(map(int, input().split())))
	l.sort()
	px = 0
	f = True
	old = 0
	ran = [m, m]
	while px < n and f:
		kk = l[px][0] - old
		left = ran[0] - kk
		right = ran[1] + kk
		if l[px][1] > right or l[px][2] < left:
			print('NO')
			f = False
			break
		else:
			new_left = max(left, l[px][1])
			new_right = min(right, l[px][2])
			ran = [new_left, new_right]
			old = l[px][0]
			px += 1
	if f:
		print('YES')


import sys
import copy
from math import *
input = sys.stdin.readline

def bo(i):
	return ''.join(list(i)[::-1])

def can(a):
	return 1
t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		s = [int(x) for x in input().split()]
		a.append(s)
	a.sort()
	d = [[0, 0, 0] for i in range(n)]
	if m < a[0][1]:
		if a[0][1] - m > a[0][0]:
			print('NO')
			continue
	elif m > a[0][2]:
		if m - a[0][2] > a[0][0]:
			print('NO')
			continue
	d[0][0] = a[0][0]
	d[0][1] = max(a[0][1], m - a[0][0])
	d[0][2] = min(a[0][2], m + a[0][0])
	flag = 0
	for i in range(1, n):
		if d[i - 1][2] + a[i][0] - a[i - 1][0] < a[i][1]:
			flag = 1
			break
		if d[i - 1][1] + a[i - 1][0] - a[i][0] > a[i][2]:
			flag = 1
			break
		d[i][0] = a[i][0]
		d[i][1] = max(a[i][1], d[i - 1][1] + a[i - 1][0] - a[i][0])
		d[i][2] = min(a[i][2], d[i - 1][2] + a[i][0] - a[i - 1][0])
	print('YES' if flag == 0 else 'NO')


for _ in range(int(input())):
	(N, T) = map(int, input().split())
	L = []
	for i in range(N):
		L.append(list(map(int, input().split())))
	abhiL = T
	abhiU = T
	prev = 0
	FLAG = 0
	for i in range(N):
		Timenow = L[i][0]
		Low = L[i][1]
		Up = L[i][2]
		diff = Timenow - prev
		abhiL = abhiL - diff
		abhiU = abhiU + diff
		if abhiU < Low:
			FLAG = 1
			break
		elif abhiL > Up:
			FLAG = 1
			break
		elif abhiL >= Low and abhiU <= Up:
			abhiL = abhiL
			abhiU = abhiU
		elif abhiL <= Low and abhiU >= Up:
			abhiL = Low
			abhiU = Up
		elif abhiL <= Low and abhiU <= Up:
			abhiL = Low
		elif abhiL <= Up and abhiU >= Up:
			abhiU = Up
		prev = Timenow
	if FLAG == 0:
		print('YES')
	else:
		print('NO')


def solv():
	(x, initt) = map(int, input().split())
	curt = 0
	tmin = initt
	tmax = initt
	pos = 0
	for n in range(x):
		(tm, l, r) = map(int, input().split())
		d = tm - curt
		curt = tm
		b = tmax + d
		a = tmin - d
		if b < l or a > r:
			pos = 1
		if l >= a and r <= b:
			tmin = l
			tmax = r
		elif a < l and l <= b and (r >= b):
			tmin = l
			tmax = b
		elif l <= a and a <= r and (r < b):
			tmin = a
			tmax = r
		elif l <= a and b <= r:
			tmin = max(l, a)
			tmax = min(b, r)
	print('YNEOS'[pos::2])
for _ in range(int(input())):
	solv()


from math import factorial
from collections import Counter
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	N = int(input())
	for _ in range(N):
		(n, m) = RL()
		ll = hh = m
		start = 0
		tag = False
		for _ in range(n):
			(time, lo, hi) = RL()
			if tag:
				continue
			ll -= time - start
			hh += time - start
			start += time - start
			if hi < ll or lo > hh:
				print('NO')
				tag = True
			if lo >= ll and hi <= hh:
				(ll, hh) = (lo, hi)
			elif lo <= ll and hi <= hh:
				(ll, hh) = (ll, hi)
			elif lo >= ll and hi >= hh:
				(ll, hh) = (lo, hh)
		if tag == False:
			print('YES')
main()


for _ in range(int(input())):
	(n, t0) = map(int, input().split())
	(t1, l, h) = map(int, input().split())
	gap = t1 - 0
	f = 0
	l_l = t0 - gap
	h_l = t0 + gap
	if l > h_l or l_l > h:
		f = 0
	else:
		f += 1
	l_p = max(t0 - gap, l)
	h_p = min(t0 + gap, h)
	for i in range(1, n):
		(ti, l, h) = map(int, input().split())
		gap = ti - t1
		l_l = l_p - gap
		h_l = h_p + gap
		if l > h_l or l_l > h:
			f = 0
		else:
			f += 1
		t1 = ti
		l_p = max(l_l, l)
		h_p = min(h_l, h)
	if f == n:
		print('YES')
	else:
		print('NO')


t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		arr.append([t, l, h])
	flag = True
	ma = m
	mi = m
	temp = m
	pre_time = 0
	for i in range(n):
		ch = arr[i][0] - pre_time
		ma = ma + ch
		mi = mi - ch
		pre_time = arr[i][0]
		if ma < arr[i][1] or mi > arr[i][2]:
			flag = False
			break
		ma = min(ma, arr[i][2])
		mi = max(mi, arr[i][1])
	if flag:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict as d
t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	lh = d(list)
	times = []
	for _a in range(n):
		(t, l, h) = [int(x) for x in input().split()]
		lh[t].append((l, h))
		times.append(t)
	lh2 = dict()
	for t in times:
		left = -float('inf')
		right = float('inf')
		for (l, h) in lh[t]:
			left = max(left, l)
			right = min(right, h)
		lh2[t] = [left, right]
	cmin = cmax = m
	ct = 0
	ok = True
	for t in times:
		(l, h) = lh2[t]
		cmin = cmin - (t - ct)
		cmax = cmax + (t - ct)
		ct = t
		if l > h:
			ok = False
			break
		if l > cmax or h < cmin:
			ok = False
			break
		cmin = max(cmin, l)
		cmax = min(cmax, h)
	if ok:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		a.append((t, l, h))
	prev = [m, m]
	prev_time = 0
	for i in range(n):
		(t, l, h) = a[i]
		curr = [prev[0] - (t - prev_time), prev[1] + (t - prev_time)]
		if curr[0] > h or curr[1] < l:
			print('NO')
			break
		else:
			prev = [max(l, curr[0]), min(h, curr[1])]
		prev_time = t
	else:
		print('YES')


q = int(input())
for _ in range(q):
	ans = True
	(n, m) = map(int, input().split())
	(cur_t, cur_l, cur_h) = (0, m, m)
	for i in range(n):
		(t, l, h) = map(int, input().split())
		(cur_l, cur_h) = (cur_l - (t - cur_t), cur_h + (t - cur_t))
		cur_l = max(cur_l, l)
		cur_h = min(cur_h, h)
		cur_t = t
		if cur_h < cur_l:
			ans = False
	if ans:
		print('YES')
	else:
		print('NO')


def main():
	(n, m) = map(int, input().split())
	(t, l, h) = ([], [], [])
	for i in range(n):
		(t1, t2, t3) = map(int, input().split())
		t.append(t1)
		l.append(t2)
		h.append(t3)
	(mn, mx) = (m, m)
	last = 0
	for i in range(n):
		k = t[i] - last
		if l[i] <= mx + k and h[i] >= mn - k:
			mx = min(mx + k, h[i])
			mn = max(mn - k, l[i])
		else:
			print('NO')
			return
		last = t[i]
	print('YES')
	return
q = int(input())
while q > 0:
	main()
	q -= 1


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
mod = 1000000007
for i in range(I()):
	(n, m) = li()
	a = []
	for i in range(n):
		a.append(li())
	(p, q) = (m, m)
	t = 0
	flag = 1
	for i in range(n):
		(d, e, f) = a[i]
		p -= d - t
		q += d - t
		t = d
		if f < p or e > q:
			flag = 0
			break
		p = max(p, e)
		q = min(q, f)
	if flag:
		print('YES')
	else:
		print('NO')


row1 = int(input())
for r1 in range(row1):
	l1 = input().split(' ')
	row2 = int(l1[0])
	tem = int(l1[1])
	a = tem
	b = tem
	t1 = 0
	state = 0
	for r2 in range(row2):
		l2 = input().split(' ')
		t2 = int(l2[0])
		c = int(l2[1])
		d = int(l2[2])
		a = a + t1 - t2
		b = b + t2 - t1
		if a <= d and b >= c:
			a = max(a, c)
			b = min(b, d)
			t1 = t2
		else:
			state = 1
	if state == 1:
		print('NO')
	else:
		print('YES')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	tlh = [list(map(int, input().split())) for i in range(n)]
	tlh.sort()
	(li, hi) = (m, m)
	now = 0
	for i in range(n):
		(t, l, h) = tlh[i]
		tmp = t
		t -= now
		now = tmp
		li -= t
		hi += t
		if hi < l or h < li:
			print('NO')
			break
		elif li <= l <= h <= hi:
			li = l
			hi = h
		elif l <= li <= hi <= h:
			li = li
			hi = hi
		elif l <= li <= h <= hi:
			li = li
			hi = h
		elif li <= l <= hi <= h:
			li = l
			hi = hi
	else:
		print('YES')


q = int(input())
for _ in range(q):
	(n, m) = list(map(int, input().split()))
	cus = []
	for i in range(n):
		(t, l, h) = list(map(int, input().split()))
		cus.append((t, l, h))
	r = [m, m]
	x = 0
	flag = 0
	for c in cus:
		r[0] -= c[0] - x
		r[1] += c[0] - x
		if r[0] > c[2] or c[1] > r[1]:
			flag = 1
			break
		else:
			r[0] = max([r[0], c[1]])
			r[1] = min([r[1], c[2]])
			x = c[0]
	if flag == 0:
		print('YES')
	else:
		print('NO')


q = int(input())
while q > 0:
	cust = []
	(n, cTemp) = [int(ele) for ele in input().split()]
	cTime = 0
	minTemp = cTemp
	maxTemp = cTemp
	flag = 1
	res = 'YES'
	for _ in range(n):
		(t, l, h) = [int(ele) for ele in input().split()]
		minTemp -= t - cTime
		maxTemp += t - cTime
		if max(l, minTemp) > min(h, maxTemp):
			res = 'NO'
		minTemp = max(l, minTemp)
		maxTemp = min(h, maxTemp)
		cTime = t
	print(res)
	q -= 1


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	tlh = [tuple(map(int, input().split())) for i in range(n)]
	m_t = m
	M_t = m
	flag = True
	prev = 0
	for (t, l, h) in tlh:
		m_t -= t - prev
		M_t += t - prev
		prev = t
		if m_t <= l and l <= M_t or (m_t <= h and h <= M_t) or (m_t > l and M_t < h):
			m_t = max(m_t, l)
			M_t = min(M_t, h)
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import sys

def I():
	return sys.stdin.readline().rstrip()
for _ in range(int(I())):
	(n, m) = map(int, I().split())
	(st, sl, sh) = (0, m, m)
	ans = True
	for c in range(n):
		(t, l, h) = map(int, I().split())
		sl -= t - st
		sh += t - st
		if sl > h or sh < l:
			ans = False
		else:
			sl = max(l, sl)
			sh = min(h, sh)
		st = t
	print('YES' if ans else 'NO')


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	flag = 0
	mn = k
	mx = k
	prev = 0
	for i in range(n):
		(ti, l, h) = map(int, input().split())
		if mx <= l:
			res = l - mx
			if res > ti - prev:
				flag = 1
			else:
				mn = l
				mx = min(h, mx + (ti - prev))
				prev = ti
		elif h <= mn:
			res = mn - h
			if res > ti - prev:
				flag = 1
			else:
				mn = max(l, mn - (ti - prev))
				mx = h
				prev = ti
		elif l >= mn and h <= mx:
			mn = l
			mx = h
			prev = ti
		elif l <= mn and h >= mx:
			mn = max(l, mn - (ti - prev))
			mx = min(h, mx + (ti - prev))
			prev = ti
		elif l >= mn and h >= mx:
			mn = l
			mx = min(h, mx + (ti - prev))
			prev = ti
		elif l <= mn and h <= mx:
			mn = max(l, mn - (ti - prev))
			mx = h
			prev = ti
	if flag == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	(t, l, h) = ([], [], [])
	for i in range(n):
		(ti, li, hi) = [int(i) for i in input().split()]
		t.append(ti)
		l.append(li)
		h.append(hi)
	mini = m - t[0]
	maxi = m + t[0]
	if mini <= h[0] and maxi >= l[0]:
		mini = max(mini, l[0])
		maxi = min(maxi, h[0])
		temp = 0
		for i in range(1, n):
			mini = mini - (t[i] - t[i - 1])
			maxi = maxi + (t[i] - t[i - 1])
			if mini <= h[i] and maxi >= l[i]:
				mini = max(mini, l[i])
				maxi = min(maxi, h[i])
			else:
				temp = 1
				break
	else:
		temp = 1
	if temp == 1:
		print('NO')
	else:
		print('YES')


def min(a, b):
	if a > b:
		return b
	else:
		return a

def max(a, b):
	if a > b:
		return a
	else:
		return b

def getminmax(list, mini, maxi, pt):
	l = list[1]
	r = list[2]
	mn = mini - (list[0] - pt)
	mx = maxi + (list[0] - pt)
	if l > mx or r < mn:
		bool = False
	else:
		bool = True
	pt = list[0]
	return (max(mn, l), min(r, mx), pt, bool)
n = int(input())
while n:
	n -= 1
	(a, i) = input().split()
	a = int(a)
	mini = int(i)
	maxi = int(i)
	pt = 0
	bool = True
	while a:
		a -= 1
		list = [int(i) for i in input().split()]
		(mini, maxi, pt, bool1) = getminmax(list, mini, maxi, pt)
		bool = bool1 and bool
	if bool:
		print('yes')
	else:
		print('no')


def getIntersection(a, b):
	return [max(a[0], b[0]), min(a[1], b[1])]
for T in range(int(input().strip())):
	(n, m) = [int(i) for i in input().strip().split(' ')]
	val = True
	a = {}
	for ni in range(n):
		(ti, li, hi) = [int(i) for i in input().strip().split(' ')]
		if a.get(ti) == None:
			a[ti] = [li, hi]
		else:
			temp = a[ti]
			temp = getIntersection(temp, [li, hi])
			if temp[0] > temp[1]:
				val = False
			a[ti] = temp
	if not val:
		print('NO')
		continue
	a = list(a.items())
	a.sort()
	curr = [m, m]
	time = 0
	for (ti, [li, hi]) in a:
		(curr[0], curr[1]) = (curr[0] - (ti - time), curr[1] + (ti - time))
		time = ti
		curr = getIntersection(curr, [li, hi])
		if curr[0] > curr[1]:
			val = False
			break
	if val:
		print('YES')
	else:
		print('NO')


import sys

def run_case():
	(n, m) = map(int, input().split())
	up = m
	lo = m
	pre = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		up += t - pre
		lo -= t - pre
		pre = t
		up = min(up, h)
		lo = max(lo, l)
		if up < lo:
			print('NO')
			for _ in range(i + 1, n):
				input()
			return
	print('YES')
t = int(input())
for _ in range(t):
	run_case()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for _ in range(n)]
	a.sort()
	(ub, lb, ts) = (m, m, 0)
	for (nts, nlb, nub) in a:
		ub = min(ub + (nts - ts), nub)
		lb = max(lb - (nts - ts), nlb)
		ts = nts
		if ub < nlb or lb > nub:
			print('NO')
			break
	else:
		print('YES')


tc = int(input())

def check(visitors, temp):
	lo = temp
	hi = temp
	time = 0
	for (cur_time, cur_temp_lo, cur_temp_hi) in visitors:
		time_passed = cur_time - time
		min_lo = lo - time_passed
		max_hi = hi + time_passed
		if min_lo > cur_temp_hi:
			return False
		if max_hi < cur_temp_lo:
			return False
		lo = max(min_lo, cur_temp_lo)
		hi = min(max_hi, cur_temp_hi)
		time = cur_time
	return True
for _ in range(tc):
	(n_vis, t) = map(int, input().split())
	visitors = []
	for _ in range(n_vis):
		visitors.append([int(o) for o in input().split()])
	print('YES' if check(visitors, t) else 'NO')


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	t = inin()
	for _ in range(t):
		(n, k) = cin()
		a = []
		for i in range(n):
			(x, y, z) = cin()
			a.append((x, y, z))
		p = k
		q = k
		ans = 'YES'
		f = 0
		for i in range(n):
			x = a[i][0] - f
			f = a[i][0]
			y = a[i][1]
			z = a[i][2]
			p = p - x
			q = q + x
			p = max(p, y)
			q = min(q, z)
			if q < p:
				ans = 'NO'
				break
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


def solve() -> bool:
	(n, temperature) = map(int, input().split())
	up = low = temperature
	time = 0
	result = True
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		if not result:
			continue
		dt = t - time
		lower = low - dt
		upper = up + dt
		low = max(lower, l)
		up = min(upper, h)
		if low > up:
			result = False
		time = t
	return result
for _ in range(int(input())):
	print('YES' if solve() else 'NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	(mn, mx) = (m, m)
	prev = 0
	f = False
	for i in range(n):
		(t, l, r) = map(int, input().split())
		if f:
			continue
		dt = abs(t - prev)
		if l <= mx + dt and mn - dt <= r:
			mn = max(mn - dt, l)
			mx = min(mx + dt, r)
		else:
			print('NO')
			f = True
		prev = t
	if not f:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split(' '))
	currmax = m
	currmin = m
	chk = 1
	prevt = 0
	for x in range(n):
		(t, l, r) = map(int, input().split(' '))
		currmax = currmax + (t - prevt)
		currmin = currmin - (t - prevt)
		prevt = t
		if currmax < l or currmin > r:
			chk = 0
		currmax = min(currmax, r)
		currmin = max(currmin, l)
	if chk == 1:
		print('YES')
	else:
		print('NO')


import sys, math
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import collections as col
import math

def solve():
	(N, M) = getInts()
	minutes = col.defaultdict(lambda : col.defaultdict(int))
	flag = False
	for n in range(N):
		(time, low, high) = getInts()
		if time not in minutes:
			minutes[time]['Low'] = low
			minutes[time]['High'] = high
		else:
			(curr_low, curr_high) = (minutes[time]['Low'], minutes[time]['High'])
			(low, high) = (max(curr_low, low), min(curr_high, high))
			if high < low:
				flag = True
			minutes[time]['Low'] = low
			minutes[time]['High'] = high
	if flag:
		return 'NO'
	A = []
	for time in minutes:
		if 'Low' in minutes[time] and 'High' in minutes[time]:
			A.append((time, minutes[time]['Low'], minutes[time]['High']))
	A.sort(reverse=True)
	curr_time = 0
	curr_high = M
	curr_low = M
	while A:
		(time, low, high) = A.pop()
		curr_low = max(low, curr_low - (time - curr_time))
		curr_high = min(high, curr_high + (time - curr_time))
		if curr_high < curr_low:
			return 'NO'
		curr_time = time
	return 'YES'
T = getInt()
for t in range(T):
	print(solve())


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	clb = cub = m
	result = True
	ct = 0
	for _ in range(n):
		(t, lb, ub) = map(int, input().split())
		clb = clb - (t - ct)
		cub = cub + (t - ct)
		ct = t
		if ub < clb or lb > cub:
			result = False
		clb = max(clb, lb)
		cub = min(cub, ub)
	print('YES' if result else 'NO')


def intersect(r1, r2):
	if r1 > r2:
		(r1, r2) = (r2, r1)
	(a, b) = r1
	(c, d) = r2
	if c <= b:
		return (c, min(b, d))
	else:
		return None
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	customer = [None] * n
	for i in range(n):
		customer[i] = tuple(map(int, input().split()))
	customer = [(0, m, m)] + sorted(customer)
	ok = True
	for i in range(n - 1, -1, -1):
		timediff = customer[i + 1][0] - customer[i][0]
		newrange = (customer[i + 1][1] - timediff, customer[i + 1][2] + timediff)
		intersect_range = intersect(newrange, (customer[i][1], customer[i][2]))
		if intersect_range == None:
			ok = False
			break
		else:
			customer[i] = (customer[i][0], intersect_range[0], intersect_range[1])
	print('YES' if ok else 'NO')


q = int(input())
for i in range(q):
	(n, temp) = map(int, input().split())
	satisfiable = True
	time_prev = 0
	max_temp = min_temp = temp
	for j in range(n):
		tlh = input()
		if satisfiable:
			(t, l, h) = map(int, tlh.split())
			max_temp += t - time_prev
			min_temp -= t - time_prev
			time_prev = t
			if h < min_temp or l > max_temp:
				satisfiable = False
			max_temp = min(h, max_temp)
			min_temp = max(l, min_temp)
	if not satisfiable:
		print('NO\n')
	else:
		print('YES')


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def check(a, b):
	if a[0] <= b[0] <= a[1] or a[0] <= b[1] <= a[1] or b[0] <= a[0] <= b[1] or (b[0] <= a[1] <= b[1]):
		return True
	return False
for _ in range(ii()):
	(n, m) = mi()
	(prev_t, prev_p) = (0, [m, m])
	flag = 0
	for i in range(n):
		(t, l, h) = mi()
		diff_t = t - prev_t
		prev_p[0] -= diff_t
		prev_p[1] += diff_t
		if prev_p[0] > h or prev_p[1] < l:
			flag = 1
		else:
			prev_p[0] = max(prev_p[0], l)
			prev_p[1] = min(prev_p[1], h)
			prev_t = t
	if flag == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
from os import path
from dataclasses import dataclass
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')

@dataclass
class pair:
	F: int
	S: int
q = int(stdin.readline())
for _ in range(q):
	M = {}
	qu = []
	check = 1
	(n, m) = map(int, stdin.readline().split())
	for i in range(n):
		(t, l, h) = map(int, stdin.readline().split())
		if t not in M:
			M[t] = pair(l, h)
		elif M[t].F > h or M[t].S < l:
			check = 0
		else:
			M[t].F = max(M[t].F, l)
			M[t].S = min(M[t].S, h)
		qu.append(t)
	if check == 0:
		print('NO')
	else:
		qu = list(set(qu))
		qu.sort()
		time = 0
		l = m
		r = m
		for v in qu:
			ll = l - (v - time)
			rr = r + (v - time)
			time = v
			if ll > M[v].S or rr < M[v].F:
				check = 0
			else:
				l = max(ll, M[v].F)
				r = min(rr, M[v].S)
		print('YES' if check == 1 else 'NO')


def intersect(a1, a2, b1, b2):
	low = max(a1, b1)
	high = min(a2, b2)
	if low > high:
		return -1
	else:
		return (low, high)
q = int(input())
for _ in range(q):
	ans = 'YES'
	(n, low) = map(int, input().split())
	high = low
	time = 0
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		low -= t - time
		high += t - time
		tmp = intersect(low, high, l, h)
		if tmp == -1:
			ans = 'NO'
		else:
			(low, high) = tmp
		time = t
	print(ans)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, m) = list(map(int, input().split()))
	low = m
	high = m
	res = 'YES'
	prev_t = 0
	for _ in range(n):
		(t, l, h) = list(map(int, input().split()))
		if res == 'NO':
			continue
		low -= t - prev_t
		high += t - prev_t
		prev_t = t
		if high < l or low > h:
			res = 'NO'
			continue
		else:
			a = sorted([low, high, l, h])
			low = a[1]
			high = a[2]
	print(res)


tcases = int(input())
for i in range(tcases):
	t = [int(x) for x in input().split(' ')]
	(n, m) = t
	vset = []
	flag = True
	time = 0
	initt_1 = m
	initt_2 = m
	for j in range(n):
		v = [int(x) for x in input().split(' ')]
		td = v[0] - time
		time = v[0]
		initt_1 = max(initt_1 - td, v[1])
		initt_2 = min(initt_2 + td, v[2])
		if initt_1 > initt_2:
			flag = False
			continue
	if flag:
		print('YES')
	else:
		print('NO')


def main():
	from sys import stdin, stdout
	for _ in range(int(stdin.readline())):
		(n, m) = map(int, stdin.readline().split())
		inp = []
		for _ in range(n):
			(t, l, h) = map(int, stdin.readline().split())
			inp.append((t, l, h))
		cur_t = 0
		cur_l = cur_h = m
		inp.sort()
		for (t, l, h) in inp:
			dt = t - cur_t
			cur_t = t
			cur_l = max(cur_l - dt, l)
			cur_h = min(cur_h + dt, h)
			if cur_l > cur_h:
				stdout.write('NO\n')
				break
		else:
			stdout.write('YES\n')
main()


for _ in range(int(input())):
	(n, m) = list(map(int, input().strip().split()))
	(low, high) = (m, m)
	time = 0
	flag = True
	for _ in range(n):
		(t, l, h) = list(map(int, input().strip().split()))
		low = low - (t - time)
		high = high + (t - time)
		time = t
		if low > h or high < l:
			flag = False
		else:
			low = max(low, l)
			high = min(high, h)
	if flag == True:
		print('YES')
	else:
		print('NO')


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	q = int(input())
	for i in range(q):
		(n, m) = map(int, input().split())
		res = [(0, m, m)]
		for j in range(n):
			(t, l, h) = map(int, input().split())
			res.append((t, l, h))
		f = True
		(start, end) = (res[0][1], res[0][2])
		for j in range(1, n + 1):
			temp = res[j][0] - res[j - 1][0]
			(low, high) = (start - temp, end + temp)
			if low > res[j][2] or high < res[j][1]:
				f = False
				break
			(start, end) = (max(low, res[j][1]), min(high, res[j][2]))
		if f:
			print('YES')
		else:
			print('NO')
main()


z = int(input())
while z:
	z -= 1
	(n, m) = map(int, input().strip().split(' '))
	l = []
	for _ in range(n):
		l.append(list(map(int, input().strip().split(' '))))
	start = m
	end = m
	t = 0
	flag = False
	for i in l:
		d = i[0] - t
		t = i[0]
		start += d
		end -= d
		if start >= i[2] and end <= i[2]:
			start = i[2]
		if start >= i[1] and end <= i[1]:
			end = i[1]
		if start > i[2] or start < i[1]:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
cases = int(input())
for q in range(cases):
	(n, m) = list(map(int, input().split()))
	tlh = [[0, m, m]]
	for i in range(n):
		(ti, li, hi) = list(map(int, input().split()))
		tlh.append([ti, li, hi])
	tlh = sorted(tlh)
	for i in range(1, n + 1):
		(ti, li, hi) = tlh[i]
		(pti, pli, phi) = tlh[i - 1]
		delta = ti - pti
		low = pli - delta
		high = phi + delta
		f = 0
		if low <= li and high >= hi:
			pass
		elif low >= li and high <= hi:
			li = low
			hi = high
		elif high >= li and high <= hi:
			hi = high
		elif low >= li and low <= hi:
			li = low
		else:
			f = 1
		if f == 1:
			break
		else:
			tlh[i] = [ti, li, hi]
	if f == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	a = []
	(n, m) = map(int, input().split())
	for i in range(n):
		(t, l, r) = map(int, input().split())
		a.append([t, l, r])
	maxi = 0
	mini = 0
	(L, R) = (m, m)
	f = 0
	t1 = 0
	for i in range(n):
		(t, l, r) = (a[i][0], a[i][1], a[i][2])
		time = t - t1
		L -= time
		R += time
		L = max(L, l)
		R = min(r, R)
		if r < L or R < l:
			f = 1
			break
		t1 = t
	if f == 0:
		print('YES')
	else:
		print('No')


import sys
input = sys.stdin.readline
q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		(t, l, r) = map(int, input().split())
		a.append([t, l, r])
	a.sort()
	flag = 0
	r = [m - a[0][0], m + a[0][0]]
	for i in range(n):
		if a[i][1] >= r[0] and a[i][2] <= r[1]:
			r = [a[i][1], a[i][2]]
		elif a[i][1] >= r[0] and a[i][1] <= r[1]:
			r = [a[i][1], r[1]]
		elif a[i][2] >= r[0] and a[i][2] <= r[1]:
			if a[i][2] > r[1]:
				g = r[1]
			else:
				g = a[i][2]
			r = [r[0], g]
		elif r[0] >= a[i][1] and r[1] <= a[i][2]:
			pass
		else:
			flag = 1
			break
		if i != n - 1:
			y = abs(a[i][0] - a[i + 1][0])
			r[0] -= y
			r[1] += y
	if flag == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = (m, m)
	tm = 0
	ans = 'YES'
	for i in range(n):
		(t, l, u) = map(int, input().split())
		a = a - (t - tm)
		b = b + (t - tm)
		tm = t
		(a, b) = (max(a, l), min(b, u))
		if a > b:
			ans = 'NO'
	print(ans)


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	l = [tuple(map(int, input().split())) for _ in range(n)]
	l = l[::-1]
	prev_T = l[0][0]
	L = l[0][1]
	R = l[0][2]
	flag = False
	for i in range(1, n):
		(ti, li, ri) = l[i]
		T = prev_T - ti
		L = max(li, L - T)
		R = min(ri, R + T)
		if L > R:
			print('NO')
			flag = True
			break
		prev_T = ti
	if flag:
		continue
	if L - l[-1][0] <= m and m <= R + l[-1][0]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	j = 0
	(pt, l1, r1) = (0, m, m)
	for i in range(n):
		(t, lo, up) = map(int, input().split())
		l1 -= t - pt
		r1 += t - pt
		pt = t
		l1 = max(lo, l1)
		r1 = min(up, r1)
		if l1 > r1:
			j += 1
	if j == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lo = []
	hi = []
	t = []
	for i in range(n):
		(x, y, z) = map(int, input().split())
		t.append(x)
		lo.append(y)
		hi.append(z)
	prev = 0
	mx = m
	mn = m
	fg = 0
	for i in range(n):
		mx += t[i] - prev
		mn -= t[i] - prev
		if mx < lo[i] or mn > hi[i]:
			fg = 1
			break
		mx = min(mx, hi[i])
		mn = max(mn, lo[i])
		prev = t[i]
	if fg:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for _ in range(n):
		(a, b, c) = map(int, input().split())
		l.append([a, b, c])
	f = 0
	mx = m
	mn = m
	prev_time = 0
	for i in range(n):
		mx += l[i][0] - prev_time
		mn -= l[i][0] - prev_time
		if l[i][1] > mx or mn > l[i][2]:
			f = 1
			break
		mx = min(mx, l[i][2])
		mn = max(mn, l[i][1])
		prev_time = l[i][0]
	if f == 1:
		print('No')
	else:
		print('Yes')


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve(n, m):
	if n >= m:
		return n - m
	if m % 2:
		return 1 + solve(n, m + 1)
	return 1 + solve(n, m // 2)

def main():
	(n, m) = get_tuple()
	prev = 0
	mn = m
	mx = m
	ans = 'YES'
	inp = []
	for _ in range(n):
		(t, l, r) = get_tuple()
		inp.append([t, l, r])
	for (t, l, r) in inp:
		mn = mn - (t - prev)
		mx = mx + (t - prev)
		if mn > r or mx < l:
			ans = 'NO'
			break
		mx = min(mx, r)
		mn = max(mn, l)
		prev = t
	print(ans)
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


def rangeMatch(a, b, x, y):
	if b < x or y < a:
		return -1
	return (max(a, x), min(b, y))
for _ in range(int(input())):
	(N, t0) = map(int, input().split())
	Store = []
	for i in range(N):
		(time, lt, ht) = map(int, input().split())
		Store.append((time, lt, ht))
	Store.sort()
	TIME = 0
	flag = 1
	ActualRange = [t0, t0]
	for i in range(N):
		ChangeTime = Store[i][0] - TIME
		RangeCanBe = [ActualRange[0] - ChangeTime, ActualRange[1] + ChangeTime]
		X = rangeMatch(RangeCanBe[0], RangeCanBe[1], Store[i][1], Store[i][2])
		if X == -1:
			print('NO')
			flag = 0
			break
		ActualRange = [X[0], X[1]]
		TIME = Store[i][0]
	if flag:
		print('YES')


def is_possible(m, customers):
	(mi, mx) = (m, m)
	t = 0
	for customer in customers:
		mi = mi - (customer[0] - t)
		mx = mx + (customer[0] - t)
		if customer[1] > mx or customer[2] < mi:
			return 'NO'
		mi = max(mi, customer[1])
		mx = min(mx, customer[2])
		t = customer[0]
	return 'YES'
T = int(input().strip())
for t in range(T):
	(n, m) = list(map(int, input().strip().split()))
	customers = []
	for i in range(n):
		customers.append(tuple(map(int, input().strip().split())))
	print(is_possible(m, customers))


for _ in range(int(input())):
	(n, t) = map(int, input().split(' '))
	ini = [t, t]
	initime = 0
	L = []
	H = []
	T = []
	for _ in range(n):
		(time, l, h) = map(int, input().split(' '))
		T.append(time)
		L.append(l)
		H.append(h)
	for i in range(n):
		time = T[i]
		l = L[i]
		h = H[i]
		ini = [ini[0] - (time - initime), ini[1] + (time - initime)]
		if l < ini[0]:
			if h < ini[0]:
				f = 1
			elif h > ini[1]:
				ini = [ini[0], ini[1]]
				f = 0
			elif h >= ini[0] or h <= ini[1]:
				ini = [ini[0], h]
				f = 0
		elif l > ini[1]:
			f = 1
		elif h > ini[1]:
			ini = [l, ini[1]]
			f = 0
		elif h < ini[1]:
			ini = [l, h]
			f = 0
		elif h == ini[1]:
			ini = [l, ini[1]]
			f = 0
		initime = time
		if f == 1:
			break
	if f == 1:
		print('No')
	else:
		print('Yes')


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter
import math
from itertools import groupby

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a / gcd(a, b) * b
q = I()
for _ in range(q):
	(n, m) = lint()
	mn = m
	mx = m
	r = 0
	f = True
	for i in range(n):
		(t, l, h) = lint()
		if f:
			if mn - (t - r) <= h and mx + (t - r) >= l:
				mn = max(mn - (t - r), l)
				mx = min(mx + (t - r), h)
			else:
				f = False
		r = t
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	temps = []
	for _ in range(n):
		temps.append(list(map(int, input().split())))
	lf = m
	ri = m
	t = 0
	for i in range(n):
		ti = temps[i][0]
		l = temps[i][1]
		r = temps[i][2]
		dif = ti - t
		lf = max(lf - dif, l)
		ri = min(ri + dif, r)
		if lf > ri:
			print('NO')
			break
		t = ti
	else:
		print('YES')


test_cases = int(input(''))
tests = []
for i in range(test_cases):
	(n, m) = input('').split()
	n = int(n)
	m = int(m)
	guests = []
	for j in range(n):
		guests.append(list(map(int, input('').split())))
	tests.append((m, guests))
for (m, guests) in tests:
	last = 0
	t = guests[0][0]
	l = guests[0][1]
	h = guests[0][2]
	old_l = m - t
	old_h = m + t
	for i in range(len(guests) - 1):
		if guests[i + 1][0] == t:
			l = max(l, guests[i + 1][1])
			h = min(h, guests[i + 1][2])
		else:
			l = max(l, old_l)
			h = min(h, old_h)
			if h < l:
				print('NO')
				last = 1
				break
			old_l = l - (guests[i + 1][0] - t)
			old_h = h + (guests[i + 1][0] - t)
			t = guests[i + 1][0]
			l = guests[i + 1][1]
			h = guests[i + 1][2]
	if last:
		continue
	l = max(l, old_l)
	h = min(h, old_h)
	if h < l:
		print('NO')
		continue
	print('YES')


import string

def main():
	(n, tmp) = map(int, input().split())
	lst_min = dict()
	lst_max = dict()
	times = [0]
	for i in range(n):
		(time, low, high) = map(int, input().split())
		times.append(time)
		if time in lst_max:
			lst_min[time] = max(low, lst_min[time])
			lst_max[time] = min(high, lst_max[time])
		else:
			lst_max[time] = high
			lst_min[time] = low
	times = list(sorted(times))
	prev_range = [tmp, tmp]
	for time in range(1, len(times)):
		tm = times[time] - times[time - 1]
		mn = lst_min[times[time]]
		mx = lst_max[times[time]]
		if mx >= mn:
			if mn <= prev_range[1] + tm and mx >= prev_range[0] - tm:
				mx = min(mx, prev_range[1] + tm)
				mn = max(mn, prev_range[0] - tm)
				prev_range = [mn, mx]
			else:
				print('NO')
				return
		else:
			print('NO')
			return
	print('YES')
t = int(input())
for i in range(t):
	main()


line = input()
q = int(line)
for _ in range(q):
	line = input()
	(n, m) = [int(x) for x in line.split()]
	visitors = []
	for _ in range(n):
		line = input()
		(t, l, h) = [int(x) for x in line.split()]
		visitors.append([t, l, h])
	sorted(visitors, key=lambda visitor: visitors[0])
	answer = True
	time = 0
	(l, h) = (m, m)
	for x in visitors:
		delta = x[0] - time
		time = x[0]
		l -= delta
		h += delta
		l = max(l, x[1])
		h = min(h, x[2])
		if l > h:
			answer = False
			break
	if answer:
		print('YES')
	else:
		print('NO')


t1 = int(input())
for i2 in range(t1):
	(n, m) = map(int, input().split())
	(up, down, tb) = (m, m, 0)
	ans = 1
	x = [[0] * 3 for i in range(n)]
	for i in range(n):
		(x[i][0], x[i][1], x[i][2]) = map(int, input().split())
	x.sort()
	for i in range(n):
		up += x[i][0] - tb
		down -= x[i][0] - tb
		if down > x[i][2] or up < x[i][1]:
			ans = 0
			break
		up = min(x[i][2], up)
		down = max(x[i][1], down)
		tb = x[i][0]
	if ans == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	(n, k) = map(int, input().split())
	(mini, maxi) = (k, k)
	prev_time = 0
	flag = False
	for _ in range(n):
		(time, tmin, tmax) = map(int, input().split())
		if flag:
			continue
		mini -= time - prev_time
		maxi += time - prev_time
		if maxi < tmin or mini > tmax:
			flag = True
		(mini, maxi) = (max(tmin, mini), min(tmax, maxi))
		prev_time = time
	print('NO' if flag else 'YES')
	t -= 1


import sys
import bisect
from collections import deque

def no():
	print('NO')

def dist(z, c):
	return (z[0] - c[0]) * (z[0] - c[0]) + (z[1] - c[1]) * (z[1] - c[1])

def vec(z, c):
	return z[0] * c[1] - z[1] * c[0]

def pro(z, c):
	return [z[0] - c[0], z[1] - c[1]]

def main():
	(n, m) = [int(i) for i in sys.stdin.readline().split()]
	q = [[0, m, m]]
	(ma, mi) = (m, m)
	for i in range(n):
		q.append([int(i) for i in sys.stdin.readline().split()])
	q.sort()
	for i in range(n, 0, -1):
		q[i][0] -= q[i - 1][0]
	for i in range(1, n + 1):
		if q[i][1] <= ma + q[i][0] and q[i][2] >= mi - q[i][0]:
			ma = min(ma + q[i][0], q[i][-1])
			mi = max(mi - q[i][0], q[i][1])
		else:
			print('NO')
			return 0
	print('YES')
for i in range(int(sys.stdin.readline())):
	main()


from collections import defaultdict

def in_between(x, mn, mx):
	return x >= mn and x <= mx
for _ in range(int(input())):
	(n, m) = tuple(map(int, input().split()))
	tlh = []
	for _ in range(n):
		tlh.append(tuple(map(int, input().split())))
	guests = defaultdict(list)
	timings = [tlh[0][0]]
	for (t, l, h) in tlh:
		if t == timings[-1]:
			guests[t].append((l, h))
		else:
			timings.append(t)
			guests[t].append((l, h))
	best_limits = dict()
	for t in timings:
		(mx, mn) = (float('inf'), float('-inf'))
		for (l, h) in guests[t]:
			mx = min(h, mx)
			mn = max(l, mn)
		best_limits[t] = (mn, mx)
	(p_max, p_min) = (m, m)
	esc = 0
	possible = True
	for (t, (low, high)) in best_limits.items():
		p_max = p_max + (t - esc)
		p_min = p_min - (t - esc)
		esc = t
		p_min = max(low, p_min)
		p_max = min(high, p_max)
		if p_min > p_max:
			possible = False
			break
	if possible:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	(big, small) = ([m] * (n + 5), [m] * (n + 5))
	last = [0, 0, 0]
	ans = True
	for c in range(n):
		(t, l, h) = list(map(int, input().split()))
		dt = t - last[0]
		if l > big[c] + dt:
			ans = False
		elif h < small[c] - dt:
			ans = False
		big[c + 1] = big[c]
		small[c + 1] = small[c]
		big[c + 1] += dt
		small[c + 1] -= dt
		small[c + 1] = max(small[c + 1], l)
		big[c + 1] = min(big[c + 1], h)
		last = [t, l, h]
	print('YES' if ans else 'NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().strip().split())
	arr = []
	arr.append([0, 0, 0])
	for i in range(n):
		arr.append(list(map(int, input().split())))
	flg = 0
	l = m
	r = m
	for i in range(1, n + 1):
		diff = arr[i][0] - arr[i - 1][0]
		l = l - diff
		r = r + diff
		a_l = arr[i][1]
		a_r = arr[i][2]
		if l < a_l and r >= a_l and (r <= a_r):
			l = a_l
			r = r
		elif l >= a_l and l <= a_r and (r > a_r):
			l = l
			r = a_r
		elif l < a_l and r > a_r:
			l = a_l
			r = a_r
		elif l < a_l and r < a_l:
			flg = 1
			break
		elif l > a_r and r > a_r:
			flg = 1
			break
	if flg:
		print('NO')
	else:
		print('YES')


q = int(input())
for _ in range(q):
	(n, m) = list(map(int, input().split()))
	info = [list(map(int, input().split())) for i in range(n)]
	info = sorted(info)
	now = (m, m)
	time = 0
	flag = True
	for i in range(n):
		(t, l, h) = info[i]
		l_now = now[0] - (t - time)
		h_now = now[1] + (t - time)
		time = t
		if h < l_now or h_now < l:
			flag = False
		else:
			l_now = max(l_now, l)
			h_now = min(h_now, h)
			now = (l_now, h_now)
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	mx = m
	mn = m
	a = 0
	for i in range(n):
		(t, l, r) = map(int, input().split())
		mx += t - a
		mn -= t - a
		a = t
		if r >= mn and l <= mx:
			mn = max(mn, l)
			mx = min(mx, r)
		else:
			f = -1
	if f == -1:
		print('NO')
	else:
		print('YES')


q = int(input())

def solve():
	(n, m) = map(int, input().split())
	customers = []
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		customers.append([t, l, h])
	lo = hi = m
	time = 0
	customers.sort()
	for (t, l, h) in customers:
		delta = t - time
		lo = max(l, lo - delta)
		hi = min(h, hi + delta)
		if hi < lo:
			print('NO')
			return
		time = t
	print('YES')
for _ in range(q):
	solve()


def f(temp, a):
	t = 0
	l = temp
	h = temp
	for (time, lower, upper) in a:
		h += time - t
		l -= time - t
		if lower > h or upper < l:
			return 'NO'
		h = min(upper, h)
		l = max(l, lower)
		t = time
	return 'YES'
for i in range(int(input())):
	(n, t) = map(int, input().strip().split())
	q = []
	for j in range(n):
		(a, b, c) = map(int, input().strip().split())
		q.append((a, b, c))
	print(f(t, q))


def inBorder(newMax_t, max_t, newMin_t, min_t):
	if newMin_t < min_t and newMax_t < min_t or (newMax_t > max_t and newMin_t > max_t):
		return False
	return True
q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	minMas = [m]
	maxMas = [m]
	timeMas = [0]
	flag = True
	for j in range(n):
		(t, l, h) = map(int, input().split())
		minMas.append(l)
		maxMas.append(h)
		timeMas.append(t)
	for j in range(n, 0, -1):
		timeMas[j] -= timeMas[j - 1]
	for j in range(1, n + 1):
		newMaxTemp = maxMas[j - 1] + timeMas[j]
		newMimTemp = minMas[j - 1] - timeMas[j]
		if inBorder(newMaxTemp, maxMas[j], newMimTemp, minMas[j]):
			maxMas[j] = min(maxMas[j], maxMas[j - 1] + timeMas[j])
			minMas[j] = max(minMas[j], minMas[j - 1] - timeMas[j])
		else:
			flag = False
			print('No')
			break
	if flag:
		print('Yes')


TT = int(input())
for _ in range(0, TT):
	(n, m) = map(int, input().split())
	L = [(m, m)]
	t = [0]
	curr_mn = m
	curr_mx = m
	temp = 0
	for i in range(n):
		(ti, li, hi) = map(int, input().split())
		diff = ti - t[-1]
		curr_mn = L[-1][0] - diff
		curr_mx = L[-1][1] + diff
		if li >= curr_mn and li <= curr_mx or (hi <= curr_mx and hi >= curr_mn) or (li >= curr_mn and hi <= curr_mx) or (curr_mn >= li and curr_mx <= hi):
			e = 1
		else:
			temp = 1
		curr_mn = max(li, curr_mn)
		curr_mx = min(hi, curr_mx)
		L.append((curr_mn, curr_mx))
		t.append(ti)
	if temp == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, ini) = map(int, input().split())
	a = []
	for i in range(n):
		(x, y, z) = map(int, input().split())
		a.append([x, y, z])
	a.sort()
	(maxt, mint) = (ini, ini)
	flag = True
	curr = 0
	for i in range(n):
		l = a[i][1]
		r = a[i][2]
		t = a[i][0] - curr
		curr = a[i][0]
		mint -= t
		maxt += t
		if maxt > r and mint <= r:
			maxt = r
		if mint < l and maxt >= l:
			mint = l
		if maxt >= l and maxt <= r or (mint >= l and mint <= r):
			continue
		elif maxt > r and mint < l:
			continue
		elif maxt < l:
			flag = False
			break
		elif mint > r:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans

def ceil(a, b):
	if a % b == 0:
		return int(a / b)
	else:
		return a // b + 1
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	x = m
	y = m
	time = 0
	ans = 'YES'
	for i in range(n):
		(t, l, h) = map(int, input().split())
		a = x - t + time
		b = y + t - time
		x = max(a, l)
		y = min(b, h)
		time = t
		o = 0
		if x > y:
			ans = 'NO'
	print(ans)


def solve():
	(n, m) = map(int, input().split())
	customers = []
	for _ in range(n):
		customers.append(map(int, input().split()))
	t = 0
	mn = mx = m
	for (new_t, l, h) in customers:
		timeRem = new_t - t
		mn = mn - timeRem
		mx = mx + timeRem
		if mn > h or mx < l:
			print('NO')
			return
		mn = max(mn, l)
		mx = min(mx, h)
		t = new_t
	print('YES')
	return
t = int(input())
for _ in range(t):
	solve()


from math import ceil, sqrt, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())
t2 = ii()
while t2:
	t2 -= 1
	(n, m) = mi()
	f = 0
	l1 = m
	h1 = m
	t1 = 0
	for i in range(n):
		(t, l, h) = mi()
		x = t - t1
		t1 = t
		l1 -= x
		h1 += x
		if l1 >= l and l1 <= h:
			f1 = 1
		elif h1 >= l and h1 <= h:
			f1 = 1
		elif l >= l1 and l <= h1:
			f1 = 1
		elif h >= l1 and h <= h1:
			f1 = 1
		else:
			f = 1
		l1 = max(l, l1)
		h1 = min(h, h1)
	if f == 0:
		print('YES')
	else:
		print('NO')


q = int(input())

def evaluate_set(n, m):
	customers = []
	for i in range(n):
		(t, l, h) = map(int, input().split())
		customers.append((t, l, h))
	customers = sorted(customers, key=lambda x: x[0])
	check = True
	t_min = m
	t_max = m
	t_abs = 0
	while len(customers) > 0:
		(t, l, h) = customers.pop(0)
		t_rel = t - t_abs
		t_min_pos = t_min - t_rel
		t_max_pos = t_max + t_rel
		t_abs = t
		if t_min_pos > h or t_max_pos < l:
			check = False
			break
		t_min = max(l, t_min_pos)
		t_max = min(h, t_max_pos)
	if check:
		return 'YES'
	else:
		return 'NO'
res = []
for i in range(q):
	(n, m) = map(int, input().split())
	res.append(evaluate_set(n, m))
for item in res:
	print(item)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
from collections import defaultdict

def solve():
	(n, m) = map(int, input().split())
	flag = True
	d = defaultdict(tuple)
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if t in d:
			(ll, hh) = d[t]
			if hh < l or h < ll:
				flag = False
			else:
				nl = max(l, ll)
				nh = min(h, hh)
				d[t] = (nl, nh)
		else:
			d[t] = (l, h)
	prev = 0
	ts = sorted(d.keys())
	top = bot = m
	for ti in ts:
		nbot = bot - (ti - prev)
		ntop = top + (ti - prev)
		(l, h) = d[ti]
		if ntop < l or h < nbot:
			flag = False
			break
		bot = max(l, nbot)
		top = min(h, ntop)
		prev = ti
	if flag:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = m
	r = m
	prev = 0
	ans = 0
	for i in range(n):
		(t, tl, tr) = map(int, input().split())
		if ans == -1:
			continue
		l -= t - prev
		r += t - prev
		if r < tl or l > tr:
			ans = -1
		l = max(l, tl)
		r = min(r, tr)
		prev = t
	if ans == -1:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	a = []
	for j in range(n):
		(t, l, h) = map(int, input().split())
		a.append([t, l, h])
	old = 0
	ll = m
	hh = m
	flg = 0
	for j in a:
		hh += j[0] - old
		ll -= j[0] - old
		sa = j[0] - old
		if hh < j[1] or ll > j[2]:
			flg = 1
			break
		hh = min(hh, j[2])
		ll = max(ll, j[1])
		old = j[0]
	if flg == 1:
		print('NO')
	else:
		print('YES')


q = int(input())

def slv():
	(n, m) = map(int, input().split(' '))
	(t, l, h) = map(list, zip(*[map(int, input().split(' ')) for _ in range(n)]))
	t = [0] + t
	l = [m] + l
	h = [m] + h
	for i in range(len(t) - 1):
		nlb = l[i] - t[i + 1] + t[i]
		if l[i + 1] < nlb:
			l[i + 1] = nlb
		if h[i + 1] < nlb:
			print('NO')
			return
		nhb = h[i] + t[i + 1] - t[i]
		if h[i + 1] > nhb:
			h[i + 1] = nhb
		if l[i + 1] > nhb:
			print('NO')
			return
	print('YES')
for _ in range(q):
	slv()


n = int(input())
for _ in range(n):
	(a, tem) = map(int, input().split())
	(start, end) = (tem, tem)
	keep = 0
	flag = True
	for __ in range(a):
		(get, x, y) = map(int, input().split())
		(get, keep) = (get - keep, get)
		start -= get
		end += get
		if start <= x and end >= y:
			(start, end) = (x, y)
		elif start >= x and end <= y:
			continue
		elif start <= y and end >= y:
			end = y
		elif start <= x and end >= x:
			start = x
		else:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


p = int(input())
for i in range(p):
	(n, m) = map(int, input().split())
	maxi = m
	mini = m
	prev = 0
	flag = 1
	for i in range(n):
		(t, l, h) = map(int, input().split())
		x = mini - (t - prev)
		y = maxi + (t - prev)
		if l <= y and h >= x:
			if flag == 0:
				continue
			maxi = min(h, y)
			mini = max(l, x)
		else:
			flag = 0
		prev = t
	if flag:
		print('YES')
	else:
		print('NO')


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, m) = value()
	customer = []
	for i in range(n):
		customer.append(value())
	customer.sort()
	last_temp = (m, m)
	last_time = 0
	possible = True
	for i in customer:
		time = i[0] - last_time
		(t1, t2) = sorted(i[1:])
		if last_temp[0] - time <= t2 and t1 <= last_temp[1] + time:
			caReach = [last_temp[0] - time, last_temp[1] + time]
			last_temp = (max(t1, min(caReach)), min(t2, max(caReach)))
			last_time = i[0]
		else:
			possible = False
			break
	if possible:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	maxt = b
	mint = b
	t = [0] * a
	l = [0] * a
	h = [0] * a
	t1 = 0
	prev = 0
	for j in range(a):
		(t[j], l[j], h[j]) = map(int, input().split())
	for j in range(a):
		maxt = maxt + t[j] - prev
		mint = mint - t[j] + prev
		if maxt >= l[j] and mint <= h[j]:
			maxt = min(maxt, h[j])
			mint = max(mint, l[j])
		else:
			t1 = 1
			break
		prev = t[j]
	if t1 == 1:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	ans = True
	(count, begin) = map(int, input().split())
	previous = [0, begin, begin]
	for j in range(count):
		(moment, lower, upper) = map(int, input().split())
		time_delta = moment - previous[0]
		if lower >= previous[2]:
			temp_delta = lower - previous[2]
			previous[2] += time_delta
			if previous[2] > upper or previous[2] < lower:
				previous[2] = upper
			if previous[1] < lower or previous[1] > upper:
				previous[1] = lower
		elif upper <= previous[1]:
			temp_delta = previous[1] - upper
			previous[1] -= time_delta
			if previous[2] > upper:
				previous[2] = upper
			if previous[1] < lower:
				previous[1] = lower
		else:
			temp_delta = 0
			previous[1] -= time_delta
			previous[2] += time_delta
			if previous[2] > upper or previous[2] < lower:
				previous[2] = upper
			if previous[1] < lower or previous[1] > upper:
				previous[1] = lower
		if temp_delta > time_delta:
			ans = False
		previous[0] += time_delta
	if ans:
		print('YES')
	else:
		print('NO')


def calc(x0, guests):
	lo = hi = x0
	t = 0
	for g in guests:
		lo -= g[0] - t
		hi += g[0] - t
		if not (lo <= g[2] and hi >= g[1]):
			return 'NO'
		lo = max(g[1], lo)
		hi = min(g[2], hi)
		t = g[0]
	return 'YES'
N = int(input())
cases = []
for _ in range(N):
	(n, m) = map(int, input().split())
	c = []
	for _ in range(n):
		c.append(list(map(int, input().split())))
	cases.append([m, c])
for (m, c) in cases:
	print(calc(m, c))


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		(a, b, c) = map(int, input().split())
		l.append([a, b, c])
	start = 0
	ma = m
	mi = m
	c = 0
	for i in range(n):
		ma += l[i][0] - start
		mi -= l[i][0] - start
		start = l[i][0]
		if mi <= l[i][2] and mi >= l[i][1] or (ma <= l[i][2] and ma >= l[i][1]) or (mi <= l[i][1] and ma >= l[i][2]):
			c += 1
			if ma > l[i][2]:
				ma = l[i][2]
			if mi < l[i][1]:
				mi = l[i][1]
	if c == n:
		print('YES')
	else:
		print('NO')


import math
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	minn = m
	maxx = m
	time = 0
	flag = True
	for i in range(n):
		(t, l, h) = map(int, input().split())
		minn = minn - (t - time)
		maxx = maxx + (t - time)
		if l > maxx or h < minn:
			flag = False
		else:
			minn = max(l, minn)
			maxx = min(h, maxx)
			time = t
	if flag:
		print('YES')
	else:
		print('NO')


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def compress(S):
	(zipped, unzipped) = ({}, {})
	for (i, a) in enumerate(sorted(S)):
		zipped[a] = i
		unzipped[i] = a
	return (zipped, unzipped)
for _ in range(INT()):
	(N, M) = MAP()
	TLR = []
	S = set()
	S.add(0)
	for i in range(N):
		(t, l, r) = MAP()
		S.add(t)
		TLR.append((t, l, r))
	(zipped, unzipped) = compress(S)
	L = len(zipped)
	TLR2 = [[] for i in range(L)]
	for i in range(N):
		(t, l, r) = TLR[i]
		t = zipped[t]
		TLR2[t].append((l, r))
	TLR2[0] = (0, 0)
	for (i, li) in enumerate(TLR2[1:], 1):
		mnl = -INF
		mxr = INF
		for (l, r) in li:
			mnl = max(mnl, l)
			mxr = min(mxr, r)
		TLR2[i] = (mnl, mxr)
	mnm = mxm = M
	for (i, (l, r)) in enumerate(TLR2[1:], 1):
		move = unzipped[i] - unzipped[i - 1]
		if mnm <= l:
			if mxm + move < l:
				NO()
				break
			else:
				mnm = l
		elif mnm - move > r:
			NO()
			break
		elif mnm - move > l:
			mnm -= move
		else:
			mnm = l
		if mxm >= r:
			if mnm - move > r:
				NO()
				break
			else:
				mxm = r
		elif mxm + move < l:
			NO()
			break
		elif mxm + move < r:
			mxm += move
		else:
			mxm = r
		if mxm < mnm:
			NO()
			break
	else:
		YES()


def cango(a1, a2, l1, l2, h1, h2):
	k = [int(1)] * 4
	sr = l1 - (a2 - a1)
	hr = h1 + (a2 - a1)
	if hr < l2 or sr > h2:
		return k
	if hr <= h2 and sr >= l2:
		(k[0], k[1], k[2], k[3]) = (int(a2), int(sr), int(hr), int(0))
		return k
	if hr > h2 and sr >= l2 and (sr <= h2):
		(k[0], k[1], k[2], k[3]) = (int(a2), int(sr), int(h2), int(0))
		return k
	if hr >= l2 and hr <= h2 and (sr < l2):
		(k[0], k[1], k[2], k[3]) = (int(a2), int(l2), int(hr), int(0))
		return k
	if hr > h2 and sr < l2:
		(k[0], k[1], k[2], k[3]) = (int(a2), int(l2), int(h2), int(0))
		return k
a = int(input())
for j in range(0, a):
	l = list(map(int, input().split()))
	at = [0] * l[0]
	lt = [0] * l[0]
	ht = [0] * l[0]
	for i in range(0, l[0]):
		li = list(map(int, input().split()))
		(at[i], lt[i], ht[i]) = (li[0], li[1], li[2])
	a = 0
	for i in range(0, l[0]):
		for j in range(0, i):
			if at[i] < at[j]:
				(at[i], at[j]) = (at[j], at[i])
				(lt[i], lt[j]) = (lt[j], lt[i])
				(ht[i], ht[j]) = (ht[j], ht[i])
	k = [int(0), int(l[1]), int(l[1]), int(0)]
	for i in range(0, l[0]):
		k = cango(k[0], at[i], k[1], lt[i], k[2], ht[i])
		if k[3]:
			a = 1
			break
	if a:
		print('NO')
	else:
		print('YES')


for _mind_control in range(int(input())):
	(n, m) = map(int, input().split())
	arr = [[0, m, m]]
	(maxx, minn) = (m, m)
	for i in range(n):
		arr.append(list(map(int, input().split())))
	arr.sort()
	fl = 1
	for i in range(n, 0, -1):
		arr[i][0] -= arr[i - 1][0]
	for i in range(1, n + 1):
		if arr[i][1] <= maxx + arr[i][0] and arr[i][2] >= minn - arr[i][0]:
			maxx = min(maxx + arr[i][0], arr[i][2])
			minn = max(minn - arr[i][0], arr[i][1])
		else:
			print('NO')
			fl = 0
			break
	if fl:
		print('YES')


for q in range(int(input())):
	(n, m) = (int(i) for i in input().split())
	a = b = m
	t0 = 0
	anser = 'YES'
	for x in range(n):
		(t, l, h) = (int(j) for j in input().split())
		a -= t - t0
		b += t - t0
		t0 = t
		a = max(a, l)
		b = min(b, h)
		if a > b:
			anser = 'NO'
	print(anser)


q = int(input())
for _ in range(q):
	flag = False
	(n, temp) = map(int, input().split())
	hitemp = temp
	lowtemp = temp
	prev = 0
	q = []
	for i in range(n):
		q.append(input())
	for x in q:
		(t, lo, hi) = map(int, x.split())
		time = t - prev
		prev = t
		if hi <= lowtemp:
			if lowtemp - time > hi:
				break
			else:
				hitemp = hi
				lowtemp = max([lo, lowtemp - time])
		elif hi <= hitemp:
			hitemp = hi
			lowtemp = max([lo, lowtemp - time])
		elif lo <= lowtemp:
			hitemp = min([hi, hitemp + time])
			lowtemp = max([lo, lowtemp - time])
		elif lo <= hitemp:
			hitemp = min([hi, hitemp + time])
			lowtemp = lo
		elif hitemp + time < lo:
			break
		else:
			hitemp = min([hi, hitemp + time])
			lowtemp = lo
	else:
		flag = True
	if flag:
		print('YES')
	else:
		print('NO')


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
let = '@abcdefghijklmnopqrstuvwxyz'
for _ in range(ii()):
	(n, m) = f()
	(it, ltm, htm) = (0, m, m)
	flg = 0
	cust = [il() for i in range(n)]
	for i in range(n):
		(t, l, h) = cust[i]
		diff = t - it
		mn = ltm - diff
		mx = htm + diff
		if mx < l or mn > h:
			flg = 1
			break
		else:
			ltm = max(mn, l)
			htm = min(mx, h)
		it = t
	if flg:
		print('NO')
	else:
		print('YES')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	tls = list([0])
	lhls = [[m, m]]
	flag = True
	for i in range(n):
		(t, l, h) = map(int, input().split())
		tls.append(t)
		lhls.append([l, h])
	for i in range(n):
		ch = tls[i + 1] - tls[i]
		high = lhls[i][1] + ch
		low = lhls[i][0] - ch
		if low > lhls[i + 1][1] or high < lhls[i + 1][0]:
			flag = False
			break
		else:
			lhls[i + 1][0] = max(low, lhls[i + 1][0])
			lhls[i + 1][1] = min(high, lhls[i + 1][1])
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	ntest = int(stdin.readline())
	for test in range(ntest):
		(n, m) = [int(z) for z in stdin.readline().split()]
		um = m
		dm = m
		lastt = 0
		answer = 'YES\n'
		for i in range(n):
			(t, l, h) = [int(z) for z in stdin.readline().split()]
			dt = t - lastt
			dm = dm - dt
			um = um + dt
			if um < l or h < dm:
				answer = 'NO\n'
			lastt = t
			dm = max(dm, l)
			um = min(um, h)
		stdout.write(answer)
	return 0
main()


Q = int(input())
for qq in range(Q):
	(n, m) = map(int, input().split())
	tl = m
	th = m
	time = 0
	flag = True
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if flag:
			tl -= t - time
			th += t - time
			tl = max(tl, l)
			th = min(th, h)
			time = t
			if tl > th:
				flag = False
	print('YES' if flag else 'NO')


tt = int(input())
while tt != 0:
	(n, i_t) = map(int, input().split())
	prev_temp = [i_t, i_t]
	prev_time = 0
	f1 = 0
	for i in range(n):
		(t, mi, ma) = map(int, input().split())
		diff_t = t - prev_time
		left = max(mi, prev_temp[0] - diff_t)
		right = min(ma, diff_t + prev_temp[1])
		prev_temp[0] = left
		prev_temp[1] = right
		prev_time = t
		if mi > right or ma < left:
			f1 = 1
	if f1 == 0:
		print('YES')
	else:
		print('NO')
	tt -= 1


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, m) = R()
	st = [m, m, 0]
	ans = 'YES'
	for i in range(n):
		(t, l, r) = R()
		if ans == 'NO':
			continue
		if l >= st[0] and r <= st[1]:
			st[0] = l
			st[1] = r
			st[2] = t
		elif l < st[0] and r >= st[0] or (r > st[1] and l <= st[1]):
			st[0] = max(l, st[0] - abs(st[2] - t))
			st[1] = min(r, st[1] + abs(st[2] - t))
			st[2] = t
		elif l > st[1]:
			if st[1] + abs(st[2] - t) < l:
				ans = 'NO'
			else:
				st[0] = l
				st[1] = min(r, st[1] + abs(st[2] - t))
				st[2] = t
		elif st[0] - abs(st[2] - t) > r:
			ans = 'NO'
		else:
			st[1] = r
			st[0] = max(l, st[0] - abs(st[2] - t))
			st[2] = t
	print(ans)


import sys
import math

def input():
	return sys.stdin.readline().strip()

def iinput():
	return [int(x) for x in input().split()]

def main():
	(n, m) = iinput()
	(t1, l1, h1) = (0, m, m)
	data = []
	for i in range(n):
		data.append(iinput())
	for i in range(n):
		(t, l, h) = data[i]
		(t1, t) = (t, t - t1)
		if l <= h1 + t and h >= l1 - t:
			l1 = max(l1 - t, l)
			h1 = min(h1 + t, h)
		else:
			print('NO')
			return
	print('YES')
	return
for ______ in range(int(input())):
	main()


def ac():
	(c, h0) = input().split()
	(c, h0) = (int(c), int(h0))
	L = [input().split() for _ in range(c)]
	h = (h0, h0)
	t = 0
	for i in range(c):
		(ti, l, u) = L[i]
		(ti, l, u) = (int(ti), int(l), int(u))
		dt = ti - t
		hp = (h[0] - dt, h[1] + dt)
		if hp[0] > u or hp[1] < l:
			print('NO')
			break
		h = (max(hp[0], l), min(hp[1], u))
		t = ti
		if i == c - 1:
			print('YES')

def main():
	n = int(input())
	for i in range(n):
		ac()
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	ans = 'YES'
	l = [0, m, m]
	for j in range(n):
		l1 = list(map(int, input().split()))
		if l[2] + (l1[0] - l[0]) < l1[1] or l[1] - (l1[0] - l[0]) > l1[2]:
			ans = 'NO'
		if ans == 'YES':
			l = [l1[0], max(l1[1], l[1] - l1[0] + l[0]), min(l1[2], l[2] + l1[0] - l[0])]
	print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip()

def zap():
	(n, m) = map(int, input().split())
	mn = m
	mh = m
	k = 0
	b = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		c = t
		t -= b
		b = c
		mn = max(l, mn - t)
		mh = min(h, mh + t)
		if mh < l or mn > h:
			k += 1
	if k != 0:
		return 'NO'
	return 'YES'
for i in range(int(input())):
	print(zap())


from sys import stdin, stdout

def takeSec(elem):
	return elem[0]

def in_inter(ref, test):
	if ref[1] >= test[0] and test[1] >= ref[0]:
		return True
	else:
		return False
q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	possible = True
	visit = []
	for j in range(n):
		visit.append(list(map(int, input().split())))
	visit.sort(key=takeSec)
	current_interval = [m - visit[0][0], m + visit[0][0]]
	last_t = 0
	for v in range(len(visit)):
		if in_inter(current_interval, [visit[v][1], visit[v][2]]):
			current_interval = [max(current_interval[0], visit[v][1]), min(current_interval[1], visit[v][2])]
		else:
			possible = False
			break
		if v < len(visit) - 1:
			current_interval = [current_interval[0] - visit[v + 1][0] + visit[v][0], current_interval[1] + visit[v + 1][0] - visit[v][0]]
	if possible:
		print('YES')
	else:
		print('NO')


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		t = list(map(int, input().split()))
		l.append(t)
	flg = 1
	t = 0
	(x, y) = (m, m)
	for i in range(n):
		nx = x - (l[i][0] - t)
		ny = y + (l[i][0] - t)
		t = l[i][0]
		if nx > l[i][2] or ny < l[i][1]:
			flg = 0
			break
		else:
			x = max(l[i][1], nx)
			y = min(l[i][2], ny)
	if flg:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	(q, mm, mn) = (0, t, t)
	ans = 'YES'
	for _ in range(n):
		(c, l, r) = map(int, input().split())
		mm -= c - q
		mn += c - q
		q = c
		mm = max(mm, l)
		mn = min(mn, r)
		if mn < mm:
			ans = 'NO'
	print(ans)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(n, m) = map(int, input().split())
		customers = []
		for _ in range(n):
			customers.append(tuple(map(int, input().split())))
		customers.sort()
		ct = 0
		mnt = m
		mxt = m
		for (t, l, h) in customers:
			if mxt + (t - ct) < l or mnt - (t - ct) > h:
				print('NO')
				return
			mxt = min(mxt + (t - ct), h)
			mnt = max(mnt - (t - ct), l)
			ct = t
		print('YES')
	q = int(input())
	for _ in range(q):
		solve()
main()


test = int(input())
while test:
	(n, m) = map(int, input().split())
	t_in = 0
	l_in = h_in = m
	flg = 0
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if flg == 1:
			continue
		t_dif = t - t_in
		l_min = l_in - t_dif
		h_max = h_in + t_dif
		if h_max < l or l_min > h:
			flg = 1
		else:
			t_in = t
			l_in = max(l_min, l)
			h_in = min(h_max, h)
	if flg == 0:
		print('YES')
	else:
		print('NO')
	test -= 1


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	CUS = [tuple(map(int, input().split())) for _ in range(n)]
	CUS.sort()
	L = m
	R = m
	prv = 0
	ans = True
	for (t, l, r) in CUS:
		d = t - prv
		L -= d
		R += d
		if R < l or r < L:
			ans = False
			break
		else:
			R = min(R, r)
			L = max(L, l)
			prv = t
	if ans:
		print('YES')
	else:
		print('NO')


def intersection(a, b, c, d):
	if a > d or b < c:
		return ()
	if a <= c:
		x = c
	else:
		x = a
	if b <= d:
		y = b
	else:
		y = d
	return (x, y)
k = int(input())
while k:
	(n, m) = (int(i) for i in input().split())
	pa = m
	pb = m
	pt = 0
	res = 'YES'
	while n:
		(t, a, b) = (int(i) for i in input().split())
		if res == 'NO':
			n -= 1
			continue
		td = t - pt
		pt = t
		newInters = intersection(pa - td, pb + td, a, b)
		if len(newInters) == 0:
			res = 'NO'
		else:
			pa = newInters[0]
			pb = newInters[1]
		n -= 1
	print(res)
	k -= 1


for i in range(int(input())):
	(num, start) = map(int, input().split())
	lm = hm = start
	pstart = 0
	ans = 'Yes'
	for j in range(num):
		(time, l, h) = map(int, input().split())
		hm += time - pstart
		lm -= time - pstart
		pstart = time
		hm = min(h, hm)
		lm = max(l, lm)
		if hm < lm:
			ans = 'NO'
	print(ans)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def check(tup1, tup2):
	a1 = tup1[0]
	a2 = tup1[1]
	b1 = tup2[0]
	b2 = tup2[1]
	if b1 <= a2 and b1 >= a1 or (b2 <= a2 and b2 >= a1) or (a1 <= b2 and a1 >= b1) or (a2 <= b2 and a2 >= b1):
		return True
	return False
q = INT()
while q != 0:
	(n, m) = MAP()
	TLH = []
	for _ in range(n):
		(t, l, h) = MAP()
		TLH.append([t, l, h])
	for _ in range(n - 1, 0, -1):
		TLH[_][0] -= TLH[_ - 1][0]
	flag = 0
	currRange = (m, m)
	for i in range(n):
		t = TLH[i][0]
		l = TLH[i][1]
		h = TLH[i][2]
		currRange = (currRange[0] - t, currRange[1] + t)
		if check(currRange, (l, h)):
			currRange = (max(currRange[0], l), min(currRange[1], h))
		else:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')
	q -= 1


import datetime
time = datetime.datetime.now
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	a = [map(int, input().split()) for _ in range(n)]
	(low, up) = (m, m)
	time = 0
	check = True
	for (t, l, h) in a:
		pre = t - time
		time = t
		(low, up) = (low - pre, up + pre)
		x = max(l, low)
		y = min(up, h)
		if x > y:
			check = False
			break
		(low, up) = (x, y)
	if check:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	var = 0
	mi = m
	ma = m
	time = 0
	fin = 'YES'
	for i in range(n):
		if fin == 'YES':
			(a, b, c) = map(int, input().split())
			val = a - time
			mi -= val
			ma += val
			if b >= mi:
				mi = b
			elif mi > c:
				fin = 'NO'
			if c <= ma:
				ma = c
			elif ma < b:
				fin = 'NO'
		else:
			(a, b, c) = map(int, input().split())
		time = a
	print(fin)


def intersect(s1, s2):
	(x1, y1) = s1
	(x2, y2) = s2
	x = max(x1, x2)
	y = min(y1, y2)
	if x <= y:
		return (x, y)
	else:
		return None
testcases_num = int(input())
for testcase_i in range(testcases_num):
	(n, m) = map(int, input().split())
	cur_t = 0
	cur_l = m
	cur_h = m
	possible = True
	for i in range(n):
		(t, l, h) = map(int, input().split())
		if possible:
			(period, cur_t) = (t - cur_t, t)
			possibles = (cur_l - period, cur_h + period)
			intersection = intersect(possibles, (l, h))
			if intersection:
				(cur_l, cur_h) = intersection
			else:
				possible = False
	print('YES' if possible else 'NO')


from sys import stdin
input = stdin.readline

def sects(x1, y1, x2, y2):
	return x1 <= y2 and x2 <= y1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	x = {}
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		x[t] = x.get(t, []) + [(l, h)]
	flag = False
	a = [(0, m, m)]
	for (k, v) in x.items():
		l = max((i[0] for i in v))
		h = min((i[1] for i in v))
		if l > h:
			print('NO')
			flag = True
			break
		a.append((k, l, h))
	if not flag:
		a.sort()
		le = len(a)
		for i in range(le):
			ct = 0
			(x1, y1) = (a[i][1], a[i][2])
			for j in range(i + 1, le):
				ct += a[j][0] - a[j - 1][0]
				(x2, y2) = (a[j][1] - ct, a[j][2] + ct)
				if not (sects(x1, y1, x2, y2) or sects(x2, y2, x1, y1)):
					print('NO')
					flag = True
					break
			if flag:
				break
		if not flag:
			print('YES')


def solve(ts, n, m):
	ts.sort(key=lambda x: x[0])
	d = ts[0][0] - 0
	li = m - d
	hi = m + d
	if ts[0][2] < li or ts[0][1] > hi:
		return False
	ts[0] = (ts[0][0], max(li, ts[0][1]), min(hi, ts[0][2]))
	for i in range(1, n):
		d = ts[i][0] - ts[i - 1][0]
		li = ts[i - 1][1] - d
		hi = ts[i - 1][2] + d
		if ts[i][2] < li or ts[i][1] > hi:
			return False
		ts[i] = (ts[i][0], max(li, ts[i][1]), min(hi, ts[i][2]))
	return True

def read():
	q = int(input())
	for i in range(q):
		(n, m) = list(map(int, input().strip().split()))
		ts = []
		for i in range(n):
			(ti, li, hi) = list(map(int, input().strip().split()))
			ts.append((ti, li, hi))
		ans = solve(ts, n, m)
		if ans:
			print('YES')
		else:
			print('NO')
read()


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for x in range(n)]
	flag = 0
	left = right = m
	time = 0
	for x in range(0, n):
		if left - a[x][0] + time <= a[x][2] and a[x][1] <= right + a[x][0] - time:
			left = max(left - a[x][0] + time, a[x][1])
			right = min(right + a[x][0] - time, a[x][2])
			time = a[x][0]
		else:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')
	t -= 1


import sys
input = sys.stdin.readline
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	t = 0
	lo = hi = m
	qs = [tuple(map(int, input().split())) for __ in range(n)]
	qs.sort()
	i = 0
	flg = True
	while i < n:
		qlo = i
		while i + 1 < n and qs[i + 1][0] == qs[i][0]:
			i += 1
		i += 1
		qhi = i
		(nt, tglo, tghi) = qs[qlo]
		for iq in range(qlo + 1, qhi):
			(nt, ctglo, ctghi) = qs[iq]
			tglo = max(tglo, ctglo)
			tghi = min(tghi, ctghi)
		hi += nt - t
		lo -= nt - t
		hi = min(tghi, hi)
		lo = max(tglo, lo)
		if lo > hi:
			flg = False
			break
		t = nt
	print('YES' if flg else 'NO')


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	prevl = m
	prevh = m
	prevt = 0
	flag = 0
	for ii in range(n):
		(t, l, h) = map(int, input().split())
		if l > prevh and l - prevh > t - prevt:
			flag = 1
		elif h < prevl and prevl - h > t - prevt:
			flag = 1
		prevh = min(h, prevh + t - prevt)
		prevl = max(l, prevl - (t - prevt))
		prevt = t
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
import math
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(n, m) = read()
	tt = []
	hh = []
	ll = []
	for i in range(n):
		(t, l, h) = read()
		tt.append(t)
		ll.append(l)
		hh.append(h)
	k = 0
	mn = m
	mx = m
	flag = True
	for i in range(n):
		if ll[i] <= mx + (tt[i] - k) and hh[i] >= mn - (tt[i] - k):
			mn = max(ll[i], mn - (tt[i] - k))
			mx = min(hh[i], mx + (tt[i] - k))
			k = tt[i]
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lowtemp = m
	hightemp = m
	itime = 0
	string = ''
	for i in range(n):
		(time, l, h) = map(int, input().split())
		if string == 'NO':
			continue
		lowtemp = lowtemp - (time - itime)
		hightemp = hightemp + (time - itime)
		itime = time
		if lowtemp <= h and hightemp >= l:
			lowtemp = max(lowtemp, l)
			hightemp = min(hightemp, h)
		else:
			string = 'NO'
	if string == 'NO':
		print('NO')
	else:
		print('YES')


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, m) = inputnums()
	t = []
	l = []
	h = []
	for i in range(n):
		(t1, l1, h1) = inputnums()
		t.append(t1)
		l.append(l1)
		h.append(h1)
	prev = 0
	mn = m
	mx = m
	good = True
	for i in range(n):
		mx += t[i] - prev
		mn -= t[i] - prev
		if mx < l[i] or mn > h[i]:
			good = False
			break
		prev = t[i]
		mn = max(l[i], mn)
		mx = min(h[i], mx)
	if good:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	f = 0
	w = 0
	l = u = b
	for i in range(a):
		(x, y, z) = map(int, input().split())
		t = x - f
		f = x
		l = max(y, l - t)
		u = min(z, u + t)
		if l > u:
			w = -1
	if w == 0:
		print('YES')
	else:
		print('NO')


def examA():
	t = I()
	ans = []
	for _ in range(t):
		(x, y, a, b) = LI()
		if (y - x) % (a + b) != 0:
			cur = -1
		else:
			cur = (y - x) // (a + b)
		ans.append(cur)
	for v in ans:
		print(v)
	return

def examB():
	(N, M) = LI()
	S = [SI() for _ in range(N)]
	d = defaultdict(int)
	ok_1 = []
	ok_2 = []
	for i in range(N):
		cur = S[i]
		if d[S[i][::-1]] > 0:
			ok_2.append([d[S[i][::-1]], i + 1])
		flag = True
		for j in range(M // 2):
			if cur[j] != cur[M - 1 - j]:
				flag = False
				break
		if flag:
			ok_1.append(i + 1)
		d[cur] = i + 1
	ans = ''
	for i in range(len(ok_2)):
		ans += S[ok_2[i][0] - 1]
	if ok_1:
		ans += S[ok_1[0] - 1]
	for i in range(len(ok_2) - 1, -1, -1):
		ans += S[ok_2[i][1] - 1]
	print(len(ans))
	print(ans)
	return

def examC():
	q = I()
	for _ in range(q):
		flag = True
		(N, M) = LI()
		(t, l, h) = ([0] * (N + 1), [0] * N, [0] * N)
		for i in range(N):
			(t[i + 1], l[i], h[i]) = LI()
		curl = M
		curr = M
		for i in range(N):
			canl = l[i] - (t[i + 1] - t[i])
			canr = h[i] + (t[i + 1] - t[i])
			if canl > curr or canr < curl:
				flag = False
				break
			curl = max(l[i], curl - (t[i + 1] - t[i]))
			curr = min(h[i], curr + (t[i + 1] - t[i]))
		if flag:
			print('YES')
		else:
			print('NO')
	return

def examD():
	ans = 0
	print(ans)
	return

def examE():
	ans = 0
	print(ans)
	return

def examF():
	ans = 0
	print(ans)
	return
import sys, copy, bisect, itertools, heapq, math, random
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LSI():
	return list(map(str, sys.stdin.readline().split()))

def LS():
	return sys.stdin.readline().split()

def SI():
	return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10 ** 9 + 7
mod2 = 998244353
inf = 10 ** 18
_ep = 10 ** (-12)
alphabet = [chr(ord('a') + i) for i in range(26)]
examC()


from math import *

def intr(a, b):
	if a[0] > b[1] or b[0] > a[1]:
		return []
	else:
		return [max(a[0], b[0]), min(a[1], b[1])]

def f(x):
	return x[0]
q = int(input())
for zz in range(q):
	(n, m) = map(int, input().split())
	ha = True
	a = []
	for i in range(n):
		a.append([int(i) for i in input().split()])
	i = 0
	while i < len(a):
		if not ha:
			break
		while i < len(a) - 1 and a[i + 1][0] == a[i][0]:
			te = intr([a[i][1], a[i][2]], [a[i + 1][1], a[i + 1][2]])
			if len(te) == 0:
				ha = False
				break
			a[i][1] = te[0]
			a[i][2] = te[1]
			a.pop(i + 1)
		i += 1
	ct = 0
	cs = [m, m]
	pl = -10 ** 20
	ph = -pl
	for i in range(len(a)):
		if not ha:
			break
		(t, l, h) = a[i]
		dt = t - ct
		cs = intr(cs, [pl, ph])
		cs[0] -= dt
		cs[1] += dt
		te = intr(cs, [l, h])
		if len(te) == 0:
			ha = False
			break
		ct = t
		pl = l
		ph = h
	if ha:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(lo, hi) = (m, m)
	w = 0
	for (t, l, h) in sorted((list(map(int, input().split())) for _ in range(n))):
		d = t - w
		lo -= d
		hi += d
		lo = max(lo, l)
		hi = min(hi, h)
		w = t
		if lo > hi:
			print('NO')
			break
	else:
		print('YES')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def find_bound(cur_range, des_range, delta):
	low_temp = cur_range[0]
	high_temp = cur_range[1]
	low_temp -= delta
	high_temp += delta
	result = []
	if low_temp <= des_range[1]:
		if low_temp > des_range[0]:
			result.append(low_temp)
		else:
			result.append(des_range[0])
	else:
		result.append(False)
	if high_temp >= des_range[0]:
		if high_temp >= des_range[1]:
			result.append(des_range[1])
		else:
			result.append(high_temp)
	else:
		result.append(False)
	return tuple(result)

def handle_test(NoCustomer, InitTemp):
	t_temp = 0
	l_temp = InitTemp
	h_temp = InitTemp
	for index in range(NoCustomer):
		(t, l, h) = invr()
		delta = t - t_temp
		t_temp = t
		result = find_bound((l_temp, h_temp), (l, h), delta)
		if result[0] is not False and result[1] is not False:
			l_temp = result[0]
			h_temp = result[1]
		else:
			for remain in range(NoCustomer - index - 1):
				(t, l, h) = invr()
			return 'NO'
	return 'YES'
q = int(input())
for i in range(q):
	(n, m) = invr()
	print(handle_test(n, m))


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(N, M, TLH):
	ph = M
	pl = M
	now = 0
	for (t, l, h) in TLH:
		d = t - now
		ph += d
		pl -= d
		if pl > h or ph < l:
			return 'NO'
		ph = min(ph, h)
		pl = max(pl, l)
		now = t
	return 'YES'

def main():
	Q = read_int()
	for _ in range(Q):
		(N, M) = read_int_n()
		TLH = [read_int_n() for _ in range(N)]
		print(slv(N, M, TLH))
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		l.append(list(map(int, input().split())))
	i = 0
	curr_time = 0
	curr_min = m
	curr_max = m
	while i < n:
		curr_min = curr_min - (l[i][0] - curr_time)
		curr_max = curr_max + (l[i][0] - curr_time)
		curr_time = l[i][0]
		if l[i][2] < curr_min or l[i][1] > curr_max:
			break
		curr_min = max(curr_min, l[i][1])
		curr_max = min(curr_max, l[i][2])
		i += 1
	if i == n:
		print('YES')
	else:
		print('NO')


t1 = int(input())
for i2 in range(t1):
	(n, m) = map(int, input().split())
	(up, down, tb) = (m, m, 0)
	ans = 1
	for i in range(n):
		(t, l, h) = map(int, input().split())
		tx = t - tb
		up += tx
		down -= tx
		if down > h or up < l:
			ans = 0
		up = min(h, up)
		down = max(l, down)
		tb = t
	if ans == 0:
		print('NO')
	else:
		print('YES')


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n, m) = I()
	l = []
	for i in range(n):
		l.append(I())
	ans = 'YES'
	last = 0
	lowest = highest = m
	for i in l:
		time = i[0]
		change = time - last
		lowest = max(i[1], lowest - change)
		highest = min(i[2], highest + change)
		if lowest > highest:
			ans = 'NO'
			break
		last = time
	print(ans)


q = int(input())
for j in range(q):
	(n, m) = map(int, input().split())
	a = [[]] * n
	for i in range(0, n):
		a[i] = [int(x) for x in input().split()]
	b = [[]] * (n + 1)
	a = sorted(a, key=lambda x: x[0])
	b[0] = [0, m, m]
	for i in range(0, n):
		b[i + 1] = a[i]
	mn = m
	mx = m
	s = 1
	for i in range(0, n):
		if b[i + 1][2] >= mn - (b[i + 1][0] - b[i][0]) and b[i + 1][1] <= mx + (b[i + 1][0] - b[i][0]):
			mn = max(b[i + 1][1], mn - (b[i + 1][0] - b[i][0]))
			mx = min(b[i + 1][2], mx + (b[i + 1][0] - b[i][0]))
		else:
			s = 0
			break
	if s == 1:
		print('YES')
	else:
		print('NO')


num_t = int(input())

def intersection(p1, p2):
	(p1_l, p1_h) = p1
	(p2_l, p2_h) = p2
	return (max(p1_l, p2_l), min(p1_h, p2_h))
for _ in range(num_t):
	(n, m) = map(int, input().split())
	ranges = []
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		ranges.append((t, l, h))
	(cur_l, cur_h) = (m, m)
	last_t = 0
	for (t, l, h) in ranges:
		t -= last_t
		(next_l, next_h) = intersection((cur_l - t, cur_h + t), (l, h))
		if next_l > next_h:
			print('NO')
			break
		(cur_l, cur_h) = (next_l, next_h)
		last_t += t
	else:
		print('YES')


INF = 10 ** 10

def main():
	print = out.append
	(n, m) = get_list()
	(time, minli, maxli) = ([0], [m], [m])
	for _ in range(n):
		(a, b, c) = get_list()
		time.append(a)
		minli.append(b)
		maxli.append(c)
	for i in range(n + 1):
		for j in range(n + 1):
			maxli[j] = min(maxli[i] + abs(time[i] - time[j]), maxli[j])
			minli[j] = max(minli[i] - abs(time[i] - time[j]), minli[j])
			if maxli[j] < minli[j]:
				print('NO')
				return
	print('YES')
import sys
from collections import defaultdict, Counter
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]
print(*out, sep='\n')


from sys import stdin

def inp():
	return (ss.rstrip() for ss in stdin).__next__()

def itg():
	return int(inp())

def mpint():
	return map(int, inp().split())
for case in range(itg()):
	(n, temperature) = mpint()
	d = dict()
	ans = True
	for i in range(n):
		(t, a, b) = mpint()
		if t in d:
			(da, db) = d[t]
			if b < da or db < a:
				ans = False
			else:
				d[t] = (max(a, da), min(b, db))
				assert a <= b, 'a > b'
		else:
			d[t] = (a, b)
	if not ans:
		print('NO')
		continue
	time1 = 0
	low = high = temperature
	for time2 in sorted(d.keys()):
		move = time2 - time1
		low -= move
		high += move
		(da, db) = d[time2]
		if high < da or db < low:
			ans = False
			break
		else:
			(low, high) = (max(low, da), min(high, db))
			if low > high:
				ans = False
				break
		time1 = time2
	print('YES' if ans else 'NO')


q = int(input())
for _ in range(q):
	(n, t) = map(int, input().split())
	mini = t
	maxi = t
	raw = []
	for _ in range(n):
		raw.append(list(map(int, input().split())))
	raw.sort()
	raw = [[0, t, t]] + raw
	for i in range(1, n + 1):
		(tm, l, h) = raw[i]
		mini = max(mini - (tm - raw[i - 1][0]), l)
		maxi = min(maxi + (tm - raw[i - 1][0]), h)
		if mini > maxi:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for j in range(t):
	(n, t0) = map(int, input().split())
	arr = []
	for i in range(n):
		arr2 = list(map(int, input().split()))
		arr.append(arr2)
	mine = t0
	maxe = t0
	time = 0
	flag = 0
	for i in range(n):
		k = arr[i][0] - time
		time = arr[i][0]
		mine -= k
		maxe += k
		if mine <= arr[i][2] and maxe >= arr[i][1]:
			mine = max(mine, arr[i][1])
			maxe = min(maxe, arr[i][2])
		else:
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


def main():
	(n, m) = map(int, input().split())
	flag = True
	mn = m
	mx = m
	prev = 0
	for _ in range(n):
		(t, l, r) = map(int, input().split())
		k = t - prev
		if mx + k < l or mn - k > r:
			flag = False
		mx = min(mx + k, r)
		mn = max(mn - k, l)
		prev = t
	if flag:
		print('YES')
	else:
		print('NO')

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	L = [[0] * 3 for _ in range(n + 1)]
	L[0][0] = 0
	L[0][1] = m
	L[0][2] = m
	for i in range(n):
		(t, l, h) = map(int, input().split())
		L[i + 1][0] = t
		L[i + 1][1] = l
		L[i + 1][2] = h
	L_ = [[0] * 3 for _ in range(n + 1)]
	L_[0][0] = 0
	L_[0][1] = m
	L_[0][2] = m
	flag = True
	for i in range(n):
		min_ = L_[i][1] - (L[i + 1][0] - L[i][0])
		max_ = L_[i][2] + (L[i + 1][0] - L[i][0])
		if max_ < L[i + 1][1] or L[i + 1][2] < min_:
			flag = False
			break
		else:
			L_[i + 1][1] = max(min_, L[i + 1][1])
			L_[i + 1][2] = min(max_, L[i + 1][2])
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	tlhl = []
	for _ in range(n):
		(t, l, h) = map(int, input().split())
		tlhl.append((t, l, h))
	now_time = 0
	ub_tmp = m
	lb_tmp = m
	for i in range(n):
		(t, l, h) = tlhl[i]
		if ub_tmp + t - now_time < l or lb_tmp - t + now_time > h:
			print('NO')
			break
		ub_tmp = min(h, ub_tmp + t - now_time)
		lb_tmp = max(l, lb_tmp - t + now_time)
		now_time = t
	else:
		print('YES')


def one():
	return int(input())

def more():
	return map(int, input().split())

def lis():
	return list(map(int, input().split()))

def st():
	return input()
for _ in range(one()):
	(n, m) = more()
	l = []
	l.append([0, m, m])
	for i in range(n):
		l.append(lis())
	l.sort(key=lambda x: x[0])
	ans = True
	for i in range(len(l) - 1):
		t = l[i + 1][0] - l[i][0]
		low = l[i][1] - t
		high = l[i][2] + t
		if low <= l[i + 1][1] <= high or low <= l[i + 1][2] <= high or (l[i + 1][1] <= low and l[i + 1][2] >= high) or (low <= l[i + 1][1] and high >= l[i + 1][2]):
			if low >= l[i + 1][1]:
				l[i + 1][1] = low
			if high <= l[i + 1][2]:
				l[i + 1][2] = high
		else:
			ans = False
			break
	print('YES' if ans else 'NO')


t1 = int(input())
for _ in range(t1):
	(n, temp) = map(int, input().split())
	min1 = [0 for i in range(n + 1)]
	max1 = [0 for i in range(n + 1)]
	min1[0] = temp
	max1[0] = temp
	time = 0
	ans = 1
	for i in range(1, n + 1):
		(t, l, h) = map(int, input().split())
		spare = t - time
		time = t
		a = min1[i - 1] - spare
		b = max1[i - 1] + spare
		min1[i] = max(a, l)
		max1[i] = min(h, b)
		if max1[i] < a or min1[i] > b:
			ans = 0
	if ans == 0:
		print('NO')
	else:
		print('YES')