Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef and his son Chefu want to watch a match of their favourite football team playing against another team, which will take place today.

Unfortunately, Chef is busy in the kitchen preparing lunch, so he cannot watch the match. Therefore, every now and then, Chef asks Chefu about the current scores of the teams and Chefu tells him the score. However, Chefu sometimes does not specify the teams along with the score — for example, he could say "the score is 3 to 6", and there is no way to know just from this statement if it was their favourite team or the other team that scored 6 goals; in different statements, the order of teams may also be different. Other times, Chefu specifies which team scored how many goals.

Chef asks for the score and receives a reply $N$ times. There are two types of replies:
1 A B: their favourite team scored $A$ goals and the other team scored $B$ goals
2 A B: one team scored $A$ goals and the other scored $B$ goals

Chef is asking you to help him determine the score of his favourite team after each of Chefu's replies. After each reply, based on the current reply and all previous information (but without any following replies), tell him whether it is possible to certainly determine the number of goals scored by his favourite team.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The following $N$ lines describe Chefu's replies in the format described above.

------  Output ------
For each of Chefu's replies, print a single line containing the string "YES" if it is possible to determine the score of Chef's favourite team after this reply or "NO" if it is impossible.

------  Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 10^{4}$
$0 ≤ A, B ≤ 10^{9}$
the sum of $N$ over all test cases does not exceed $10^{5}$
there is at least one valid sequence of scored goals consistent with all replies

------  Subtasks ------
Subtask #1 (100 points): original constraints

----- Sample Input 1 ------ 
1

6

2 0 1

1 3 1

2 2 4

2 5 6

2 8 8

2 9 10
----- Sample Output 1 ------ 
NO

YES

YES

NO

YES

NO
----- explanation 1 ------ 
Example case 1:
- Reply 1: Chef cannot know who scored the first goal.
- Reply 2: Chefu told Chef that their favourite team has scored $3$ goals so far.
- Reply 3: Chef can conclude that his favourite team has scored $4$ goals, since it already scored $3$ goals earlier.
- Reply 4: the favourite team could have scored $5$ or $6$ goals, but there is no way to know which option is correct.
- Reply 5: since there is a tie, Chef knows that his favourite team has scored $8$ goals.
- Reply 6: again, Chef cannot know if his favourite team has scored $9$ or $10$ goals.

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Constructive algorithms

Ad-hoc


Solutions:
SPECIFIC = 1
UNKNOWN = 2
T = int(input())
for _ in range(T):
	N = int(input())
	t1 = 0
	t2 = 0
	for _ in range(N):
		(rtype, a, b) = map(int, input().split(' '))
		if rtype == SPECIFIC:
			(t1, t2) = (a, b)
			print('YES')
		else:
			way1 = a >= t1 and b >= t2
			way2 = b >= t1 and a >= t2
			if way1 != way2 or a == b:
				(t1, t2) = (a, b) if way1 else (b, a)
				print('YES')
			else:
				print('NO')


t = int(input())

def id_score(current, t, a, b):
	if (t == 1) | (a == b):
		current = [a, b]
		print('YES')
	elif (a >= current[0]) & (a < current[1]) | (b >= current[1]) & (b < current[0]):
		current = [a, b]
		print('YES')
	elif (a >= current[1]) & (a < current[0]) | (b >= current[0]) & (b < current[1]):
		current = [b, a]
		print('YES')
	else:
		print('NO')
	return current
for i in range(t):
	c_size = int(input())
	current = [-1, -1]
	for c in range(c_size):
		(t, a, b) = map(int, input().split())
		current = id_score(current, t, a, b)


t = int(input())
for _ in range(t):
	n = int(input())
	(p, q) = (-1, -1)
	for _ in range(n):
		(x, a, b) = map(int, input().split())
		if a == b:
			(p, q) = (a, b)
			print('YES')
			continue
		if x == 1:
			print('YES')
			(p, q) = (a, b)
			continue
		else:
			if p == -1 and q == -1:
				print('NO')
				continue
			if a < p or a < q or b < p or (b < q):
				print('YES')
				(p, q) = (a, b)
				continue
		print('NO')


for _ in range(int(input())):
	n = int(input())
	t = False
	l = [0] * n
	a = [0] * n
	b = [0] * n
	for i in range(n):
		(l[i], a[i], b[i]) = map(int, input().split())
		if a[i] == b[i]:
			print('YES')
			t = True
		elif l[i] == 1:
			print('YES')
			t = True
		elif t:
			if max(a[i - 1], b[i - 1]) > min(a[i], b[i]):
				print('YES')
				t = True
			else:
				print('NO')
				t = False
		else:
			print('NO')
			t = False


T = int(input())
for _ in range(T):
	N = int(input())
	scores = None
	for _ in range(N):
		(U, A, B) = map(int, input().split())
		if U == 1:
			scores = [A, B]
		elif U == 2:
			if A == B:
				scores = [A, B]
			elif scores is not None:
				if min([A, B]) < max(scores):
					if scores[0] < scores[1]:
						scores[0] = min([A, B])
						scores[1] = max([A, B])
					else:
						scores[0] = max([A, B])
						scores[1] = min([A, B])
				else:
					scores = None
		if scores is not None:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	i = 0
	j = 0
	for __ in range(int(input())):
		(n, I, J) = map(int, input().split())
		if n == 2:
			if (i <= I and j <= J) != (i <= J and j <= I) or I == J:
				(i, j) = (I, J) if i <= I and j <= J else (J, I)
				print('YES')
			else:
				print('NO')
		else:
			(i, j) = (I, J)
			print('YES')


T = int(input())
for t in range(T):
	N = int(input())
	ft = 0
	ot = 0
	for n in range(N):
		sc = [int(x) for x in input().split()]
		if sc[0] == 1:
			ft = sc[1]
			ot = sc[2]
			print('YES')
		elif sc[0] == 2:
			if sc[1] == sc[2]:
				ft = sc[1]
				ot = sc[1]
				print('YES')
			elif sc[1] < ft or sc[2] < ot:
				ot = sc[1]
				ft = sc[2]
				print('YES')
			elif sc[1] < ot or sc[2] < ft:
				ft = sc[1]
				ot = sc[2]
				print('YES')
			else:
				print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	for j in range(n):
		l = list(map(int, input().split()))
		if l[0] == 1:
			a = l[1:]
			print('YES')
		elif l[1] == l[2]:
			a = l[1:]
			print('YES')
		elif a == []:
			print('NO')
		elif l[1] < max(a) or l[2] < max(a):
			a = l[1:]
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = b = 0
	s = False
	for j in range(n):
		(t, a1, b1) = map(int, input().split(' '))
		if t == 1:
			print('YES')
			s = True
			a = a1
			b = b1
		elif a1 == b1:
			print('YES')
			s = True
			a = b = a1
		elif s:
			if a == b:
				print('NO')
				s = False
				(a, b) = (a1, b1)
			elif min(a1, b1) == max(a, b):
				print('NO')
				(a, b) = (a1, b1)
				s = False
			elif min(a1, b1) < max(a, b):
				if a > b:
					b = min(a1, b1)
					a = max(a1, b1)
				else:
					a = min(a1, b1)
					b = max(a1, b1)
				print('YES')
			else:
				print('NO')
				a = a1
				b = b1
				s = False
		else:
			print('NO')
			a = a1
			b = b1
			s = False


n_cases = int(input())
sc = None
for _ in range(n_cases):
	n_scores = int(input())
	for _ignore in range(n_scores):
		(type, sc0, sc1) = (int(x) for x in input().split())
		if type == 1 or sc0 == sc1:
			score_known = True
			sc = (sc0, sc1)
		elif sc is not None:
			if sc0 < sc[0]:
				sc = (sc1, sc0)
			elif sc0 < sc[1]:
				sc = (sc0, sc1)
			elif sc1 < sc[0]:
				sc = (sc0, sc1)
			elif sc1 < sc[1]:
				sc = (sc1, sc0)
			else:
				sc = None
		print('YES' if sc else 'NO')


def calc(us, them):
	new = [int(x) for x in input().split(' ')]
	if new[0] == 1 or new[1] == new[2]:
		print('YES')
		return (new[1], new[2])
	new_loser = min(new[1], new[2])
	new_winner = max(new[1], new[2])
	old_loser = min(us, them)
	old_winner = max(us, them)
	if new_loser < old_winner:
		print('YES')
		if us > them:
			return (new_winner, new_loser)
		return (new_loser, new_winner)
	print('NO')
	return (0, 0)

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		us = 0
		them = 0
		for _ in range(N):
			(us, them) = calc(us, them)
main()


x = int(input())
for _ in range(x):
	y = int(input())
	fav_team = 0
	opp_team = 0
	for _ in range(y):
		reply = list(map(int, input().split()))
		if reply[0] == 1:
			print('YES')
			fav_team = reply[1]
			opp_team = reply[2]
		elif reply[1] == reply[2]:
			fav_team = reply[1]
			opp_team = reply[2]
			print('YES')
		else:
			way1 = reply[1] >= fav_team and reply[2] >= opp_team
			way2 = reply[1] >= opp_team and reply[2] >= fav_team
			if way1 != way2:
				print('YES')
				(fav_team, opp_team) = (reply[1], reply[2]) if way1 else (reply[2], reply[1])
			else:
				print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	y = 'YES'
	(ta, tb) = (0, 0)
	for _ in range(n):
		(p, a, b) = list(map(int, input().split()))
		if p == 1:
			(ta, tb) = (a, b)
			y = 'YES'
		elif a == b:
			(ta, tb) = (a, b)
			y = 'YES'
		elif y == 'YES':
			m1 = min(a, b)
			m2 = max(a, b)
			if m1 < ta:
				y = 'YES'
				ta = m2
				tb = m1
			elif m1 < tb:
				y = 'YES'
				ta = m1
				tb = m2
			else:
				y = 'NO'
		print(y)


case = int(input())
for _ in range(case):
	n = int(input())
	(F, O) = (0, 0)
	prev = 'NO'
	for i in range(n):
		(typ, A, B) = map(int, input().split(' '))
		if A == B:
			(F, O) = (A, B)
			prev = 'YES'
			print(prev)
			continue
		elif typ == 1:
			(F, O) = (A, B)
			prev = 'YES'
			print(prev)
			continue
		elif prev == 'NO':
			print(prev)
			continue
		elif A >= max(F, O) and B >= max(F, O):
			prev = 'NO'
			print(prev)
			continue
		else:
			prev = 'YES'
			if F < O:
				F = min(A, B)
				O = max(A, B)
			else:
				F = max(A, B)
				O = min(A, B)
			print(prev)
			continue


T = int(input())
for _ in range(T):
	N = int(input())
	default = [2, 0, 0]
	for _ in range(N):
		scores = list(map(int, input().split()))
		if scores[0] == 1 or scores[1] == scores[2]:
			print('YES')
			default = [1, scores[1], scores[2]]
			continue
		if default[0] == 1 and min(scores[1], scores[2]) < max(default[1], default[2]):
			print('YES')
			default = [1, scores[2], scores[1]]
			continue
		print('NO')
		default[0] = 2


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		prev = tuple()
		for _ in range(n):
			(x, a, b) = [int(i) for i in input().split(' ')]
			if x == 1:
				print('YES')
				prev = (x, a, b)
				continue
			else:
				if a == b:
					print('YES')
					prev = (x, a, b)
					continue
				if not prev:
					print('NO')
					continue
				else:
					(x_prev, a_prev, b_prev) = prev
					if min(a, b) >= max(a_prev, b_prev):
						print('NO')
						continue
					else:
						print('YES')
						prev = (x, a, b)
						continue
main()


import heapq
from collections import *
import math

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

def factorial(n):
	fact = 1
	for i in range(1, n + 1):
		fact = fact * i
		fact %= 1000000007
	return fact

def solve():
	n = int(input())
	t = []
	for _ in range(n):
		(a, b, c) = map(int, input().split())
		t.append([a, b, c])
	(t1, t2) = (0, 0)
	for i in range(n):
		if t[i][0] == 1:
			print('YES')
			(t1, t2) = (t[i][1], t[i][2])
		else:
			l1 = t[i][1] >= t1 and t[i][2] >= t2
			l2 = t[i][1] >= t2 and t[i][2] >= t1
			if l1 != l2 or t[i][1] == t[i][2]:
				print('YES')
				if l1 == True:
					(t1, t2) = (t[i][1], t[i][2])
				else:
					(t1, t2) = (t[i][2], t[i][1])
			else:
				print('NO')
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	prev_scores = [0, 0]
	for i in range(n):
		(a, s1, s2) = map(int, input().split())
		if a == 1:
			print('YES')
			prev_scores = [s1, s2]
		elif s1 == s2:
			print('YES')
			prev_scores = [s1, s2]
		elif prev_scores[0] == prev_scores[1]:
			print('NO')
		elif max(prev_scores) <= min(s1, s2):
			print('NO')
		else:
			if prev_scores[0] > s1 and prev_scores[1] > s2:
				prev_scores = [s1, s2]
			else:
				prev_scores = [s2, s1]
			print('YES')


t = int(input())
for q in range(t):
	n = int(input())
	bol = False
	for i in range(n):
		li = list(map(int, input().split()))
		if li[0] == 1:
			print('YES')
			x = li[1:]
			bol = True
		elif li[1] == li[2]:
			print('YES')
		elif not bol:
			print('NO')
		elif max(x) > min(li[1:]):
			print('YES')
			x = li[1:]
			bol = True
		else:
			print('NO')


known = 1
unknown = 2
test_case = int(input())
for test in range(test_case):
	n = int(input())
	fav_team_score = 0
	other_team_known_score = 0
	for test_1 in range(n):
		(reply_type, a_goals, b_goals) = map(int, input().split(' '))
		if reply_type == known:
			(fav_team_score, other_team_known_score) = (a_goals, b_goals)
			print('YES')
		else:
			type_1 = a_goals >= fav_team_score and b_goals >= other_team_known_score
			type_2 = b_goals >= fav_team_score and a_goals >= other_team_known_score
			if type_1 != type_2 or a_goals == b_goals:
				(fav_team_score, other_team_known_score) = (a_goals, b_goals) if type_1 else (b_goals, a_goals)
				print('YES')
			else:
				print('NO')


T = int(input())
for _ in range(T):
	N = int(input())
	scores = [[int(s) for s in input().split()] for _ in range(N)]
	if scores[0][0] == 1 or scores[0][1] == scores[0][2]:
		(prev_s1, prev_s2) = (scores[0][1], scores[0][2])
		print('YES')
	else:
		(prev_s1, prev_s2) = (-1, -1)
		print('NO')
	for i in range(1, N):
		(curr_r, curr_s1, curr_s2) = scores[i]
		if prev_s1 == -1 and (curr_r == 2 and curr_s1 != curr_s2):
			print('NO')
		elif curr_r == 1 or curr_s1 == curr_s2 or min(curr_s1, curr_s2) < max(prev_s1, prev_s2):
			(prev_s1, prev_s2) = (curr_s1, curr_s2)
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	res = []
	for _ in range(n):
		a = list(map(int, input().split()))
		res.append(a)
	i = 0
	while i < n:
		if res[i][0] != 1 and res[i][1] != res[i][2]:
			print('NO')
		else:
			(_, x, y) = res[i]
			print('YES')
			i += 1
			break
		i += 1
	poss = True
	while i < n:
		(cur, a, b) = res[i]
		if cur == 2 and poss == False:
			if a == b:
				(x, y) = (a, b)
				poss = True
				print('YES')
			else:
				print('NO')
			i += 1
			continue
		elif cur == 1:
			print('YES')
			poss = True
			i += 1
			(x, y) = (a, b)
			continue
		poss1 = a - x >= 0 and b - y >= 0
		poss2 = b - x >= 0 and a - y >= 0
		if poss1 and poss2:
			if a == b:
				print('YES')
			else:
				poss = False
				print('NO')
			i += 1
		else:
			if poss1:
				(x, y) = (a, b)
				print('YES')
			elif poss2:
				(x, y) = (b, a)
				print('YES')
			else:
				poss = False
				print('NO')
			i += 1


t = int(input())
for _ in range(t):
	k = int(input())
	(l_k_A, l_k_B) = (0, 0)
	status = 'NO'
	for _ in range(k):
		(I, A, B) = map(int, input().split())
		if I == 1:
			status = 'YES'
			(l_k_A, l_k_B) = (A, B)
		elif I == 2:
			if A < l_k_A or B < l_k_B or B < l_k_A or (A < l_k_B):
				status = 'YES'
				(A, B) = (B, A)
				(l_k_A, l_k_B) = (A, B)
			else:
				status = 'NO'
		if A == B:
			status = 'YES'
			(l_k_A, l_k_B) = (A, B)
		print(status)


T = int(input().strip())
for _ in range(T):
	N = int(input().strip())
	runningA = None
	runningB = None
	for i in range(N):
		splits = input().strip().split()
		(C, A, B) = (int(splits[0]), int(splits[1]), int(splits[2]))
		if A == B:
			runningA = A
			runningB = B
		elif C == 1:
			runningA = A
			runningB = B
		elif runningA is not None:
			if runningA == runningB:
				runningA = None
			else:
				currMin = min(A, B)
				if currMin >= max(runningA, runningB):
					runningA = None
				elif runningA > runningB:
					runningA = A + B - currMin
					runningB = currMin
				else:
					runningA = currMin
					runningB = A + B - currMin
		if runningA is None:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	previousMax = -1
	previousStatus = 'NO'
	for _ in range(int(input())):
		(Type, ScoreA, ScoreB) = map(int, input().split())
		if Type == 1 or ScoreA == ScoreB:
			print('YES')
			previousStatus = 'YES'
		elif min(ScoreA, ScoreB) >= previousMax or previousStatus == 'NO':
			print('NO')
			previousStatus = 'NO'
		else:
			print('YES')
			previousStatus = 'YES'
		previousMax = max(ScoreA, ScoreB)


for _ in range(int(input())):
	N = int(input())
	knownA = knownB = 0
	for i in range(N):
		(X, A, B) = list(map(int, input().split()))
		if X == 1:
			print('YES')
			knownA = A
			knownB = B
			continue
		if min(A, B) < max(knownA, knownB):
			print('YES')
			knownA = A
			knownB = B
			continue
		if A == B:
			print('YES')
			knownA = A
			knownB = B
			continue
		print('NO')


t = int(input())
for _ in range(t):
	fav = 0
	oth = 0
	n = int(input())
	for _ in range(n):
		(i, a, b) = map(int, input().split())
		if i == 1:
			fav = a
			oth = b
			print('YES')
		if i == 2:
			if a == b:
				fav = a
				oth = b
				print('YES')
			elif a == fav and b == oth or (a == oth and b == fav):
				print('YES')
			elif fav == oth:
				print('NO')
			elif fav < oth:
				if fav <= min(a, b) < oth:
					print('YES')
					fav = min(a, b)
					oth = max(a, b)
				else:
					print('NO')
			elif oth < fav:
				if oth <= min(a, b) < fav:
					print('YES')
					fav = max(a, b)
					oth = min(a, b)
				else:
					print('NO')


for _ in range(int(input())):
	n = int(input())
	A = 0
	B = 0
	for __ in range(n):
		(flag, a, b) = map(int, input().split())
		if flag == 1 or a == b:
			A = a
			B = b
			print('YES')
		elif a == A and b == B:
			print('YES')
		elif a == B and b == A:
			B = a
			A = b
			print('YES')
		elif min(a, b) < max(A, B):
			if a < b:
				if A > B:
					B = a
					A = b
				else:
					A = a
					B = b
			elif A < B:
				B = a
				A = b
			else:
				A = a
				B = b
			print('YES')
		else:
			print('NO')


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

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

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

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

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = inp()
for i in range(t):
	n = inp()
	k = 0
	(X, Y) = (-1, -1)
	for i in range(n):
		(a, x, y) = mp()
		if a == 1 or x == y:
			X = x
			Y = y
			k = 1
			print('YES')
		elif k == 0:
			print('NO')
		elif min(x, y) >= max(X, Y):
			print('NO')
			k = 0
		else:
			if X > Y:
				X = max(x, y)
				Y = min(x, y)
			else:
				Y = max(x, y)
				X = min(x, y)
			print('YES')
			k = 1


n = int(input())
for i in range(n):
	y = False
	r = []
	nn = int(input())
	for j in range(nn):
		h = list(map(int, input().split(' ')))
		r.append(h)
	for k in range(len(r)):
		if r[k][1] == r[k][2] or r[k][0] == 1:
			print('YES')
			y = True
		elif y == True and (r[k][1] < max(r[k - 1][1], r[k - 1][2]) or r[k][2] < max(r[k - 1][1], r[k - 1][2])):
			print('YES')
			y = True
		else:
			print('NO')
			y = False


def solve_testcase():
	n = int(input())
	poss_states = [(0, 0)]
	for _ in range(n):
		(a, b, c) = list(map(int, input().split()))
		if a == 1 or b == c:
			poss_states = [(b, c)]
		else:
			new_states = []
			for st in poss_states:
				if st[0] <= b and st[1] <= c:
					new_states.append((b, c))
					break
			for st in poss_states:
				if st[0] <= c and st[1] <= b:
					new_states.append((c, b))
					break
			poss_states = new_states
		if len(poss_states) == 1:
			print('YES')
		else:
			print('NO')
for _ in range(int(input())):
	solve_testcase()


t = int(input())
for T in range(t):
	n = int(input())
	fav = oth = 0
	for i in range(n):
		(index, goal1, goal2) = map(int, input().split())
		if index == 1 or goal1 == goal2:
			print('YES')
			fav = goal1
			oth = goal2
		elif goal1 < fav or goal2 < fav:
			if goal1 < fav:
				oth = goal1
				fav = goal2
			else:
				oth = goal2
				fav = goal1
			print('YES')
		elif goal1 < oth or goal2 < oth:
			if goal1 < oth:
				fav = goal1
				oth = goal2
			else:
				fav = goal2
				oth = goal1
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = -1
	for i in range(n):
		(m, x, y) = map(int, input().split())
		if m == 1:
			print('YES')
			a = max(x, y)
		elif min(x, y) < a:
			print('YES')
			a = max(x, y)
		elif x == y:
			print('YES')
			a = max(x, y)
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	f = o = 0
	for _ in range(n):
		(x, a, b) = map(int, input().split())
		if x == 1:
			(f, o) = (a, b)
			print('YES')
			continue
		(a, b) = (min(a, b), max(a, b))
		if a == b:
			f = o = a
			print('YES')
		elif b >= f and b < o or f > a:
			(f, o) = (b, a)
			print('YES')
		elif b >= o and b < f or o > a:
			(f, o) = (a, b)
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	prevReply = -1
	for _ in range(int(input())):
		(format, first, second) = map(int, input().split())
		if format == 1 or first == second or min(first, second) < prevReply:
			print('YES')
			prevReply = max(first, second)
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	fav = 0
	opp = 0
	for j in range(n):
		(num, a, b) = map(int, input().split())
		if num == 1:
			print('YES')
			fav = a
			opp = b
		elif num == 2:
			if a == b:
				print('YES')
				fav = a
				opp = b
			elif min(a, b) < max(fav, opp):
				print('YES')
				if fav > opp:
					fav = max(a, b)
					opp = min(a, b)
				else:
					fav = min(a, b)
					opp = max(a, b)
			else:
				print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	p1 = 0
	p2 = 0
	for i in range(n):
		arr = list(map(int, input().split()))
		if arr[0] == 1:
			print('YES')
			p1 = arr[1]
			p2 = arr[2]
		elif arr[1] == arr[2]:
			print('YES')
			p1 = arr[1]
			p2 = arr[2]
		elif arr[1] < p1 or arr[1] < p2:
			print('YES')
			if arr[1] < p1:
				p2 = arr[1]
				p1 = arr[2]
			else:
				p1 = arr[1]
				p2 = arr[2]
		elif arr[2] < p1 or arr[2] < p2:
			print('YES')
			if arr[2] < p1:
				p1 = arr[1]
				p2 = arr[2]
			if arr[2] < p2:
				p2 = arr[1]
				p1 = arr[2]
		else:
			print('NO')
			p1 = 0
			p2 = 0


t = int(input())
for _ in range(t):
	n = int(input())
	myteam = 0
	otherteam = 0
	for _ in range(n):
		(x, y, z) = map(int, input().split())
		if y == z:
			myteam = y
			otherteam = z
			print('YES')
		elif x == 1:
			myteam = y
			otherteam = z
			print('YES')
		elif min(y, z) >= max(myteam, otherteam):
			print('NO')
		else:
			print('YES')
			if myteam < otherteam:
				myteam = min(y, z)
				otherteam = max(y, z)
			else:
				myteam = max(y, z)
				otherteam = min(y, z)


t = int(input())
while t:
	t -= 1
	n = int(input())
	fav = 0
	other = 0
	while n:
		n -= 1
		(typ, a, b) = map(int, input().split())
		if typ == 1:
			print('YES')
			fav = a
			other = b
		elif typ == 2:
			if a == b:
				print('YES')
				fav = a
				other = b
			elif min(a, b) < max(fav, other):
				print('YES')
				if fav > other:
					fav = max(a, b)
					other = min(a, b)
				else:
					fav = min(a, b)
					other = max(a, b)
			else:
				print('NO')


t = int(input())
for q in range(t):
	n = int(input())
	l1 = []
	for w in range(n):
		x = list(map(int, input().split()))
		if x[0] == 1:
			l1 = list(x)
			print('YES')
		elif x[1] == x[2]:
			print('YES')
		elif l1 == []:
			print('NO')
		elif min(x[1], x[2]) < max(l1[1], l1[2]):
			l1 = list(x)
			print('YES')
		else:
			l1 = []
			print('NO')


for tt in range(int(input())):
	n = int(input())
	(t1, t2) = (0, 0)
	flag = True
	for i in range(n):
		(a, b, c) = map(int, input().split())
		if b == c:
			t1 = b
			t2 = c
			print('YES')
			flag = False
		elif a == 1:
			t1 = b
			t2 = c
			print('YES')
			flag = False
		elif flag:
			print('NO')
		elif min(t1, t2) < max(b, c) and min(b, c) < max(t1, t2):
			print('YES')
			flag = False
			if t1 < t2:
				t1 = min(b, c)
				t2 = max(b, c)
			else:
				t2 = min(b, c)
				t1 = max(b, c)
		else:
			print('NO')
			flag = True


for _ in range(int(input())):
	previous = (1, 0, 0)
	for _ in range(int(input())):
		(m, a, b) = map(int, input().split())
		if m == 1 or a == b:
			previous = (1, a, b)
			print('YES')
		elif m == 2:
			h = max(previous[1], previous[2])
			if a >= h and b >= h or previous[0] == 2:
				previous = (2, a, b)
				print('NO')
			else:
				previous = (1, a, b)
				print('YES')


n = int(input())
for _ in range(0, n):
	m = int(input())
	team_1 = 0
	team_2 = 0
	for _ in range(0, m):
		array = list(map(int, input().split()))
		if array[0] == 1:
			print('YES')
			team_1 = array[1]
			team_2 = array[2]
		if array[0] == 2:
			if array[1] == array[2]:
				print('YES')
				team_1 = array[1]
				team_2 = array[2]
			elif min(array[1], array[2]) < max(team_1, team_2):
				print('YES')
				if team_2 > team_1:
					team_1 = min(array[1], array[2])
					team_2 = max(array[1], array[2])
				else:
					team_2 = min(array[1], array[2])
					team_1 = max(array[1], array[2])
			else:
				print('NO')


t = int(input())
for _ in range(t):
	reply = int(input())
	replies = list()
	for _ in range(reply):
		replies.append(list(map(int, input().split())))
	fteam = 0
	oteam = 0
	for i in range(len(replies)):
		if replies[i][0] == 1:
			fteam = replies[i][1]
			oteam = replies[i][2]
			print('YES')
		elif replies[i][1] == replies[i][2]:
			print('YES')
			fteam = replies[i][1]
			oteam = replies[i][2]
		elif fteam >= oteam:
			if replies[i][1] >= fteam and replies[i][2] < fteam:
				fteam = replies[i][1]
				oteam = replies[i][2]
				print('YES')
			elif replies[i][2] >= fteam and replies[i][1] < fteam:
				fteam = replies[i][2]
				oteam = replies[i][1]
				print('YES')
			else:
				print('NO')
		elif replies[i][1] >= oteam and replies[i][2] < oteam:
			fteam = replies[i][2]
			oteam = replies[i][1]
			print('YES')
		elif replies[i][2] >= oteam and replies[i][1] < oteam:
			fteam = replies[i][2]
			oteam = replies[i][1]
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	fav = 0
	n_fav = 0
	for i in range(int(input())):
		(t, a, b) = map(int, input().split())
		if t == 1:
			fav = a
			n_fav = b
			print('YES')
		elif a == b:
			fav = a
			n_fav = b
			print('YES')
		elif fav >= n_fav:
			if a >= fav and b < fav:
				fav = a
				n_fav = b
				print('YES')
			elif b >= fav and a < fav:
				fav = b
				n_fav = a
				print('YES')
			else:
				print('NO')
		elif a >= n_fav and b < n_fav:
			n_fav = a
			fav = b
			print('YES')
		elif b >= n_fav and a < n_fav:
			n_fav = b
			fav = a
			print('YES')
		else:
			print('NO')


import copy
for q in range(int(input())):
	n = int(input())
	a = [3]
	b = []
	for i in range(n):
		a = list(map(int, input().strip().split()))
		if a[0] == 1:
			b = list(a)
			print('YES')
		elif a[1] == a[2]:
			print('YES')
		elif b == []:
			print('NO')
		elif min(a[1], a[2]) < max(b[1], b[2]):
			b = list(a)
			print('YES')
		else:
			b = []
			print('NO')


import copy
for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		a = list(map(int, input().strip().split()))
		if a[0] == 1:
			l = list(a)
			print('YES')
		elif a[1] == a[2]:
			print('YES')
		elif l == []:
			print('NO')
		elif min(a[1], a[2]) < max(l[1], l[2]):
			l = list(a)
			print('YES')
		else:
			l = []
			print('NO')


for _ in range(int(input())):
	(a, b) = (0, 0)
	for i in range(int(input())):
		(typ, one, two) = map(int, input().split())
		if typ == 1:
			print('YES')
			(a, b) = (one, two)
		elif one == two:
			print('YES')
			(a, b) = (one, two)
		elif min(one, two) >= max(a, b):
			print('NO')
		elif a > b:
			a = max(one, two)
			b = min(one, two)
			print('YES')
		elif b > a:
			a = min(one, two)
			b = max(one, two)
			print('YES')
		else:
			print('NO')


def main():
	T = int(input())
	if T not in range(1, 101):
		return
	for t in range(T):
		N = int(input())
		if N not in range(1, 10001):
			return
		score = [0, 0]
		for n in range(N):
			reply = input()
			reply_split = reply.split(' ')
			(case, A, B) = (int(reply_split[0]), int(reply_split[1]), int(reply_split[2]))
			if A not in range(0, 10 ** 9 + 1) or B not in range(0, 10 ** 9 + 1):
				return
			if case == 1:
				print('YES')
				score = [A, B]
			elif case == 2:
				if A == B:
					print('YES')
					score = [A, B]
				elif A < score[0] or B < score[1]:
					print('YES')
					score = [B, A]
				elif B < score[0] or A < score[1]:
					print('YES')
					score = [A, B]
				else:
					print('NO')
main()


T = int(input())
for t in range(T):
	req = int(input())
	mem_ind = -1
	a_mem = -1
	b_mem = -1
	for r in range(req):
		(ind, a, b) = map(int, input().split(' '))
		if ind == 1:
			print('YES')
			mem_ind = 1
			a_mem = a
			b_mem = b
		elif a == b:
			print('YES')
			mem_ind = 1
			a_mem = a
			b_mem = b
		elif mem_ind == 1 and min(a, b) < max(a_mem, b_mem):
			print('YES')
			a_mem = min(a, b)
			b_mem = max(a, b)
			mem_ind = 1
		else:
			print('NO')
			mem_ind = -1


for _ in range(int(input())):
	x = -1
	for i in range(int(input())):
		(p, a, b) = map(int, input().split())
		if p == 1 or a == b or min(a, b) < x:
			print('YES')
			x = max(a, b)
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	a = -1
	for i in range(n):
		(k, g1, g2) = [int(j) for j in input().split()]
		if k == 1 or g1 == g2 or min(g1, g2) < a:
			print('YES')
			a = max(g1, g2)
		else:
			print('NO')


def score(t, a, b, prev_a, prev_b):
	if t or a == b:
		return (a, b)
	if prev_a is None:
		return (None, None)
	if a < prev_a or b < prev_b:
		return (b, a)
	if a < prev_b or b < prev_a:
		return (a, b)
	return (None, None)
for _ in range(int(input())):
	prev_a = prev_b = None
	for _ in range(int(input())):
		(t, a, b) = [int(x) for x in input().split()]
		(prev_a, prev_b) = score(True if t == 1 else False, a, b, prev_a, prev_b)
		if prev_a is None:
			print('NO')
		else:
			print('YES')


T = int(input())
for i in range(T):
	r = int(input())
	prev = [0, 0]
	track = False
	for i in range(r):
		(p, f, l) = map(int, input().split(' '))
		dif = abs(prev[0] - prev[1])
		lscored = min(f, l) - min(prev[0], prev[1])
		scored = f + l - prev[0] - prev[1]
		if p == 1:
			lk = f
			print('YES')
			track = True
		elif f == l:
			lk = f
			track = True
			print('YES')
		elif track and scored <= dif:
			track = True
			print('YES')
		elif track and scored > dif and (lscored < dif):
			track = True
			print('YES')
		else:
			track = False
			print('NO')
		prev[0] = f
		prev[1] = l


for testcases in range(int(input())):
	n = int(input())
	m = -1
	for i in range(n):
		(a, b, c) = map(int, input().split())
		if a == 1 or b == c or min(b, c) < m:
			print('YES')
			m = max(b, c)
		else:
			print('NO')


T = int(input())
for charachter in range(T):
	number_ask = int(input())
	goal = []
	leader = 0
	res = -1
	i = 0
	for item in range(number_ask):
		answer = 'unknown'
		est = list(map(int, input().split(' ')))
		known = est[0]
		del est[0]
		est.sort()
		if known == 1 or est[0] == est[1]:
			answer = 'YES'
			res = i + 1
		elif est[0] < leader and res == i:
			answer = 'YES'
			res = i + 1
		else:
			answer = 'NO'
		leader = est[1]
		i += 1
		print(answer)


t = int(input())
for j1 in range(t):
	n = int(input())
	score = [0, 0, 0]
	for j2 in range(n):
		inpt = input()
		reply = []
		for x in inpt.split():
			reply.append(int(x))
		if reply[0] == 1:
			print('YES')
			score[0] = 1
			score[1] = reply[1]
			score[2] = reply[2]
		elif reply[1] == reply[2]:
			score[0] = 1
			score[1] = reply[1]
			score[2] = reply[2]
			print('YES')
		elif score[0] == 1:
			flag = 0
			for i in range(1, 3):
				if flag == 0:
					for j in range(1, 3):
						if reply[j] < score[i]:
							flag = 1
							score[0] = 1
							score[3 - i] = reply[j]
							score[i] = reply[3 - j]
							break
				else:
					break
			if flag == 1:
				print('YES')
			else:
				score[0] = 0
				score[1] = reply[1]
				score[2] = reply[2]
				print('NO')
		else:
			score[0] = 0
			score[1] = reply[1]
			score[2] = reply[2]
			print('NO')


for T in range(int(input())):
	n = int(input())
	temp = 0
	was1 = False
	for x in range(n):
		(val, num1, num2) = map(int, input().split())
		if num1 == num2:
			print('YES')
		elif val == 1:
			print('YES')
			was1 = True
		elif val == 2 and was1:
			if temp > min(num1, num2):
				print('YES')
			else:
				print('NO')
				was1 = False
		else:
			print('NO')
		temp = max(num1, num2)


T = int(input())
for t in range(T):
	N = int(input())
	a = 0
	b = 0
	for n in range(N):
		reply = list(map(int, input().split()))
		if reply[0] == 1:
			a = reply[1]
			b = reply[2]
			print('YES')
		elif reply[0] == 2:
			if reply[1] == reply[2]:
				a = reply[1]
				b = reply[1]
				print('YES')
			elif min(reply[1], reply[2]) >= max(a, b):
				print('NO')
			elif a > b:
				a = max(reply[1], reply[2])
				b = min(reply[1], reply[2])
				print('YES')
			elif a < b:
				a = min(reply[1], reply[2])
				b = max(reply[1], reply[2])
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	n = int(input())
	A = 0
	B = 0
	while n:
		(x, a, b) = map(int, input().split())
		if x == 1:
			A = a
			B = b
			print('YES')
		elif a == b:
			A = a
			B = b
			print('YES')
		elif A <= a and A <= b and (B <= a) and (B <= b):
			print('NO')
		elif A <= a and B <= b:
			print('YES')
			A = a
			B = b
		elif A <= b and B <= a:
			print('YES')
			A = b
			B = a
		else:
			print('NO')
		n -= 1


import math
for _ in range(int(input())):
	fav = 0
	op = 0
	for _ in range(int(input())):
		(t, a, b) = map(int, input().split())
		if t == 1:
			fav = a
			op = b
			print('YES')
		else:
			more = max(fav, op)
			less = min(fav, op)
			if less <= a < more or less <= b < more:
				if fav == less:
					fav = min(a, b)
					op = max(a, b)
				else:
					fav = max(a, b)
					op = min(a, b)
				print('YES')
			elif b == a:
				print('YES')
				fav = a
				op = a
			else:
				print('NO')


for i in range(int(input())):
	b = -1
	for j in range(int(input())):
		a = list(map(int, input().split()))
		if a[0] == 1 or a[1] == a[2] or min(a[1], a[2]) < b:
			print('YES')
			b = max(a[1], a[2])
		else:
			print('NO')


T = int(input())
for cases in range(T):
	N = int(input())
	prev_reply = []
	for _ in range(N):
		reply = list(map(int, input().split()))
		if reply[1] == reply[2]:
			print('YES')
			prev_reply = reply
			continue
		if reply[0] == 2:
			if prev_reply == []:
				print('NO')
				continue
			if reply[1] < max(prev_reply[1:]) or reply[2] < max(prev_reply[1:]):
				print('YES')
				prev_reply = reply
				continue
			print('NO')
		if reply[0] == 1:
			print('YES')
			prev_reply = reply
			continue


t = int(input())
for w in range(t):
	n = int(input())
	x = 0
	y = 0
	for i in range(n):
		(p, a, b) = map(int, input().split(' '))
		if p == 1:
			print('YES')
			x = a
			y = b
		if p == 2:
			if a == b:
				print('YES')
				x = a
				y = b
				continue
			if a < x or b < y:
				print('YES')
				x = b
				y = a
				continue
			if a >= x and a < y:
				print('YES')
				x = a
				y = b
				continue
			if b >= x and b < y:
				print('YES')
				x = b
				y = a
				continue
			if a >= y and a < x:
				print('YES')
				x = b
				y = a
				continue
			if b >= y and b < x:
				print('YES')
				x = a
				y = b
				continue
			print('NO')