Four players participate in the playoff tournament. The tournament is held according to the following scheme: the first player will play with the second, and the third player with the fourth, then the winners of the pairs will play in the finals of the tournament.

It is known that in a match between two players, the one whose skill is greater will win. The skill of the $i$-th player is equal to $s_i$ and all skill levels are pairwise different (i. e. there are no two identical values in the array $s$).

The tournament is called fair if the two players with the highest skills meet in the finals.

Determine whether the given tournament is fair.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

A single line of test case contains four integers $s_1, s_2, s_3, s_4$ ($1 \le s_i \le 100$) — skill of the players. It is guaranteed that all the numbers in the array are different.


-----Output-----

For each testcase, output YES if the tournament is fair, or NO otherwise.


-----Examples-----

Input
4
3 7 9 5
4 5 6 9
5 3 8 1
6 5 3 2
Output
YES
NO
YES
NO


-----Note-----

Consider the example:

in the first test case, players $2$ and $3$ with skills $7$ and $9$ advance to the finals;

in the second test case, players $2$ and $4$ with skills $5$ and $9$ advance to the finals. The player with skill $6$ does not advance, but the player with skill $5$ advances to the finals, so the tournament is not fair;

in the third test case, players $1$ and $3$ with skills $5$ and $8$ advance to the finals;

in the fourth test case, players $1$ and $3$ with skills $6$ and $3$ advance to the finals. The player with skill $5$ does not advance, but the player with skill $3$ advances to the finals, so the tournament is not fair.

Difficulty: EASY
Tags: Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	mx1 = max(a, b)
	mx2 = max(c, d)
	if mx1 < c and mx1 < d or (mx2 < a and mx2 < b):
		print('NO')
	else:
		print('YES')


def Superman():
	ScarletWitch = list(map(int, input().split()))
	(Deadpool, Death, Falcon, Cap) = ScarletWitch
	if Deadpool > Death:
		Wolverine = Deadpool
	else:
		Wolverine = Death
	if Falcon > Cap:
		DoctorStrange = Falcon
	else:
		DoctorStrange = Cap
	ScarletWitch.sort()
	Jormungandr = [Wolverine, DoctorStrange]
	Jormungandr.sort()
	if ScarletWitch[2] == Jormungandr[0] and ScarletWitch[3] == Jormungandr[1]:
		print('YES')
	else:
		print('NO')
Thanos = 1
Thanos = int(input())
for Gamora in range(Thanos):
	Superman()


n = int(input())
for b in range(n):
	already_answered = False
	y = input().split(' ')
	arr = [int(x) for x in y]
	matches = [[arr[0], arr[1]], [arr[2], arr[3]]]
	top = max(arr)
	arr.remove(max(arr))
	second = max(arr)
	for c in matches:
		if top in c and second in c:
			print('NO')
			already_answered = True
	if not already_answered:
		print('YES')


ans = []
for _ in range(int(input())):
	s = [*map(int, input().split())]
	sx = sorted(s)
	if {max(s[0:2]), max(s[2:4])} - {sx[2], sx[3]}:
		ans += ['NO']
	else:
		ans += ['YES']
print('\n'.join(ans))


t = int(input())
l = []
for i in range(t):
	s = input().split()
	s = [int(i) for i in s]
	(a, b, c, d) = (s[0], s[1], s[2], s[3])
	one = max(a, b)
	two = max(c, d)
	s.sort(reverse=True)
	if max(one, two) == s[0] and min(one, two) == s[1]:
		l.append('YES')
	else:
		l.append('NO')
for i in l:
	print(i)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	l = []
	if a > b:
		s1 = a
	else:
		s1 = b
	if c > d:
		s2 = c
	else:
		s2 = d
	l.append(a)
	l.append(b)
	l.append(c)
	l.append(d)
	l.sort()
	if l[len(l) - 1] == s1 and l[len(l) - 2] == s2 or (l[len(l) - 1] == s2 and l[len(l) - 2] == s1):
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
from heapq import *

def main():
	for _ in range(int(input())):
		s = list(map(int, input().split()))
		a = sorted(s)
		if a[-1] in s[:2] and a[-2] in s[2:] or (a[-2] in s[:2] and a[-1] in s[2:]):
			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
from math import gcd, sqrt
sys.setrecursionlimit(10 ** 5)
inf = float('inf')
en = lambda x: list(enumerate(x))
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	(a, b, c, d) = r()
	arr = [a, b, c, d]
	arr.sort()
	x = max(a, b)
	y = max(c, d)
	if x > y:
		(x, y) = (y, x)
	if [x, y] == [arr[-2], arr[-1]]:
		print('YES')
	else:
		print('NO')
for _ in range(ii()):
	solve()


for _ in ' ' * int(input()):
	(a, c, b, d) = map(int, input().split())
	print('YNEOS'[a > b and a > d and (c > b) and (c > d) or (b > a and b > c and (d > a) and (d > c))::2])


t = int(input())
for i in range(t):
	(s1, s2, s3, s4) = map(int, input().split())
	a = max(s1, s2)
	b = max(s3, s4)
	if a > b:
		if b > s1 and b < s2 or (b < s1 and b > s2):
			print('YES')
		else:
			print('NO')
	elif a > s3 and a < s4 or (a < s3 and a > s4):
		print('YES')
	else:
		print('NO')


def solve():
	(a1, a2, a3, a4) = map(int, input().strip().split(' '))
	if (a3 > a2 and a3 > a1) and (a4 > a2 and a4 > a1) or ((a1 > a3 and a1 > a4) and (a2 > a3 and a2 > a4)):
		print('NO')
	else:
		print('YES')
for _ in range(int(input())):
	solve()


ans = []
for i in range(int(input())):
	arr = list(map(int, input().split()))
	(a, b) = (max(arr[:2]), max(arr[2:]))
	if sorted([a, b]) == sorted(arr)[2:]:
		ans.append('YES')
	else:
		ans.append('NO')
print(*ans, sep='\n')


t = int(input())
lst2 = []
for x in range(0, t):
	lst = list(map(int, input().split()))
	max1 = max(lst[:2])
	max2 = max(lst[2:])
	lst.remove(max1)
	lst.remove(max2)
	max3 = max(lst)
	if max3 > max1 or max3 > max2:
		lst2.append('NO')
	else:
		lst2.append('YES')
for x in lst2:
	print(x)


import sys, math, itertools
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for w in wtf[1:]:
	S = list(map(int, w.split()))
	print('YES' if max(S[:2]) > min(S[2:]) and max(S[2:]) > min(S[:2]) else 'NO')


t = int(input())
for i in range(t):
	lis = [int(i) for i in input().split()]
	a = max(lis[0], lis[1])
	b = max(lis[2], lis[3])
	if a + b >= lis[0] + lis[1] and a + b >= lis[2] + lis[3]:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	l = input().split()
	l = [int(l[i]) for i in range(4)]
	t -= 1
	counta = 0
	countb = 0
	large = 0
	slarge = 0
	for i in range(4):
		if large < l[i]:
			slarge = large
			large = l[i]
		elif slarge < l[i]:
			slarge = l[i]
	for i in range(2):
		if l[i] == slarge or l[i] == large:
			counta += 1
	for i in range(2, 4):
		if l[i] == slarge or l[i] == large:
			countb += 1
	if counta == 1:
		print('YES')
	else:
		print('NO')


def fair(s):
	if min(s[0], s[1]) > max(s[2], s[3]) or min(s[2], s[3]) > max(s[0], s[1]):
		return 'NO'
	else:
		return 'YES'
t = int(input())
tests = []
for i in range(t):
	s = input().split()
	tests.append([int(a) for a in s])
for s in tests:
	print(fair(s))


import sys
from bisect import bisect_left as lb
from collections import deque
from queue import PriorityQueue as pq
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
for _ in range(ii()):
	s = il()
	b = sorted(s)
	fl = 1
	for i in range(2):
		if (b[-1] == s[2 * i] or b[-1] == s[2 * i + 1]) and (b[-2] == s[2 * i] or b[-2] == s[2 * i + 1]):
			fl = 0
			break
	if fl:
		print('YES')
	else:
		print('NO')


def fairplay(array):
	player1 = player2 = 0
	notSelected1 = notSelected2 = 0
	if array[0] > array[1]:
		player1 = array[0]
		notSelected1 = array[1]
	else:
		player1 = array[1]
		notSelected1 = array[0]
	if array[2] > array[3]:
		player2 = array[2]
		notSelected2 = array[3]
	else:
		player2 = array[3]
		notSelected2 = array[2]
	if player2 < notSelected1 or player1 < notSelected2:
		print('NO')
	else:
		print('YES')
testCases = int(input())
for t in range(testCases):
	array = list(map(int, input().split()))
	fairplay(array)


(a, d) = (int(input()), [])
for i in range(0, a):
	b = [int(i) for i in input().split()]
	h1 = b.index(max(b))
	b[h1] = -1
	h2 = b.index(max(b))
	if h1 > 1 and h2 > 1 or (h1 < 2 and h2 < 2):
		d.append('NO')
	else:
		d.append('YES')
print(*d, sep='\n')


n = int(input())
for i in range(n):
	s = input()
	s = s.split()
	s = [int(x) for x in s]
	min1 = max(s[:2])
	min2 = max(s[2:])
	if min1 < min(s[2:]) or min2 < min(s[:2]):
		print('NO')
	else:
		print('YES')


result = []
for i in range(int(input())):
	array = input().split()
	array = list(map(lambda x: int(x), array))
	array2 = sorted(array)
	max1 = array2[2]
	max2 = array2[3]
	win1 = max(array[0], array[1])
	win2 = max(array[2], array[3])
	if max1 in [win1, win2] and max2 in [win1, win2]:
		result.append('YES')
	else:
		result.append('NO')
for i in result:
	print(i)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	Y = [a, b, c, d]
	Y.sort(reverse=True)
	if (max(a, b) == Y[0] or max(a, b) == Y[1]) and (max(c, d) == Y[0] or max(c, d) == Y[1]):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(m, n, o, p) = map(int, input().split())
	a = max(m, n)
	b = min(m, n)
	c = max(o, p)
	d = min(o, p)
	if c > b and a > d:
		print('YES')
	else:
		print('NO')


def solve():
	(a, b, c, d) = map(int, input().split())
	max1 = max(a, b)
	min1 = min(a, b)
	max2 = max(c, d)
	min2 = min(c, d)
	if max1 > min2 and max2 > min1:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	solve()


import sys
import math

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

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

def write(x):
	sys.stdout.write(x)
for i in '.' * int(input()):
	(a, b, c, d) = read_ints()
	if min(a, b) > max(c, d) or min(c, d) > max(a, b):
		write('NO\n')
	else:
		write('YES\n')


n = int(input())
for i in range(n):
	sp = list(map(int, input().split()))
	max1 = max(sp)
	sp_ = sp[:]
	sp_.remove(max1)
	max2 = max(sp_)
	s1 = max(sp[0:2])
	s2 = max(sp[2:])
	if set([s1, s2]) == set([max1, max2]):
		print('YES')
	else:
		print('NO')


result = ''
for i in range(0, int(input())):
	num = input()
	l = list(map(int, num.split()))
	m1 = [l[0], l[1]]
	m2 = [l[2], l[3]]
	if max(m1) >= min(m2) and max(m2) >= min(m1):
		result += 'YES\n'
	else:
		result += 'NO\n'
print(result)


t = int(input())
for tt in range(1, t + 1):
	(a, b, c, d) = map(int, input().split())
	max1 = max(a, b)
	min1 = min(a, b)
	max2 = max(c, d)
	min2 = min(c, d)
	if max2 < min1 or max1 < min2:
		print('NO')
	else:
		print('YES')


x = int(input())
l = []
for i in range(x):
	t = tuple(map(int, input().split()))
	if t[0] > t[1]:
		A = t[0]
	else:
		A = t[1]
	if t[2] > t[3]:
		B = t[2]
	else:
		B = t[3]
	if A == t[0] and B == t[2] and (A < t[3] or B < t[1]):
		l.append('NO')
	elif A == t[1] and B == t[2] and (A < t[3] or B < t[0]):
		l.append('NO')
	elif A == t[0] and B == t[3] and (A < t[2] or B < t[1]):
		l.append('NO')
	elif A == t[1] and B == t[3] and (A < t[2] or B < t[0]):
		l.append('NO')
	else:
		l.append('YES')
for x in l:
	print(x)


t = int(input())
while t != 0:
	a = list(map(int, input().split()))
	b = a.copy()
	a.sort()
	a.reverse()
	if (a[0] == b[0] or a[0] == b[1]) and (a[1] == b[2] or a[1] == b[3]) or ((a[1] == b[0] or a[1] == b[1]) and (a[0] == b[2] or a[0] == b[3])):
		print('YES')
	else:
		print('NO')
	t -= 1


test_case = int(input())
for i in range(0, test_case):
	(p1, p2, p3, p4) = map(int, input().split())
	if p1 > p2:
		a = p1
		a1 = p2
	else:
		a = p2
		a1 = p1
	if p3 > p4:
		b = p3
		b1 = p4
	else:
		b = p4
		b1 = p3
	if a < b1:
		print('NO')
	elif b < a1:
		print('NO')
	else:
		print('YES')


T = int(input())
for _ in range(T):
	(a, b, c, d) = map(int, input().split())
	if max(a, b) < min(c, d) or max(c, d) < min(a, b):
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(0, n):
	l = [int(x) for x in input().split()]
	f1 = max(l[0], l[1])
	f2 = max(l[2], l[3])
	m1 = max(l)
	l.remove(m1)
	m2 = max(l)
	if (m1 == f1 or m1 == f2) and (m2 == f2 or m2 == f1):
		print('YES')
	else:
		print('NO')


arr = []
for i in range(int(input())):
	arr.append(list(map(int, input().split())))
for x in arr:
	tmp = x[:]
	tmp.sort(reverse=True)
	tmp = tmp[:2]
	if max(x[:2]) in tmp and max(x[2:]) in tmp:
		print('YES')
	else:
		print('NO')


n = int(input())
res = ''
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	(x, y) = (max(a, b), max(c, d))
	if min(a, b) > y or min(c, d) > x:
		res += 'NO\n'
	else:
		res += 'YES\n'
print(res)


t = int(input())
while t > 0:
	(a, b, c, d) = map(int, input().split())
	max1 = max(a, b)
	max2 = max(c, d)
	flag = 0
	if max1 < c and max1 < d:
		flag = 1
	if max2 < a and max2 < b:
		flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')
	t = t - 1


n = int(input())
a = []
for i in range(n):
	temp = list(map(int, input().split()))
	x = max(temp[0], temp[1])
	y = max(temp[2], temp[3])
	if x < min(temp[2], temp[3]) or y < min(temp[0], temp[1]):
		a.append('NO')
	else:
		a.append('YES')
for i in range(n):
	print(a[i])


from sys import stdin

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

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

def li():
	return list(mi())

def si():
	return stdin.readline()
t = 1
t = ii()
for _ in range(t):
	(a, b, c, d) = mi()
	l1 = [a, b, c, d]
	l1.sort(reverse=True)
	e = l1[0]
	f = l1[1]
	if e == a and f == b or (e == b and f == a) or (e == c and f == d) or (e == d and f == c):
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	if min(a, b) > max(c, d) or min(c, d) > max(a, b):
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	b = a.copy()
	a.sort(reverse=True)
	c = []
	c.append(max(b[0], b[1]))
	c.append(max(b[2], b[3]))
	c.sort(reverse=True)
	if c == a[0:2]:
		print('YES')
	else:
		print('NO')


t = int(input())
arr = []
for _ in range(t):
	arr.append(list(map(int, input().split())))
for _ in range(t):
	ar = arr[_]
	max1 = max(ar[:2])
	max2 = max(ar[2:])
	ar.remove(max1)
	ar.remove(max2)
	if max1 > ar[1] and max2 > ar[0]:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(a, b, c, d) = map(int, input().split())
	ls = [a, b, c, d]
	max1 = max(a, b)
	max2 = max(c, d)
	max_a = max1 if max1 < max2 else max2
	max3 = max(ls)
	ls.remove(max(ls))
	max4 = max(ls)
	max_b = max3 if max3 < max4 else max4
	t -= 1
	if max_a == max_b:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	arr = input().split(' ')
	fmax = int(arr[0])
	smax = int(arr[1])
	for j in arr:
		j = int(j)
		if j > fmax:
			fmax = j
	for k in arr:
		k = int(k)
		if k > smax and k < fmax:
			smax = k
	if smax == fmax:
		smax = int(arr[2])
	for k in arr:
		k = int(k)
		if k > smax and k < fmax:
			smax = k
	if str(smax) in arr[:2] and str(fmax) in arr[2:]:
		print('YES')
	elif str(fmax) in arr[:2] and str(smax) in arr[2:]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = [int(x) for x in input().split()]
	x = max(l[0], l[1])
	y = max(l[2], l[3])
	l.sort()
	if (x == l[2] or x == l[3]) and (y == l[2] or y == l[3]):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input().split()
	for i in range(len(s)):
		s[i] = int(s[i])
	if max(s[0], s[1]) < min(s[2], s[3]) or max(s[2], s[3]) < min(s[0], s[1]):
		print('NO')
	else:
		print('YES')


test_cases = int(input())
for _ in range(test_cases):
	skill_levels = [int(x) for x in input().split()]
	sorted_skill_levels = sorted(skill_levels)
	first_max = max(skill_levels[0], skill_levels[1])
	second_max = max(skill_levels[2], skill_levels[3])
	if first_max == sorted_skill_levels[-2] and second_max == sorted_skill_levels[-1] or (first_max == sorted_skill_levels[-1] and second_max == sorted_skill_levels[-2]):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	s = sorted([a, b, c, d])
	best = set(s[-2:])
	print('no' if a in best and b in best or (c in best and d in best) else 'yes')


for _ in range(int(input())):
	(s1, s2, s3, s4) = map(int, input().split())
	if min(s1, s2) > max(s3, s4) or max(s1, s2) < min(s3, s4):
		print('NO')
	else:
		print('YES')


n = int(input())
score = []
for i in range(n):
	a = list(map(int, input().split()))
	m1 = max(a[0], a[1])
	m2 = max(a[2], a[3])
	res = max(m1, m2)
	if m1 <= a[2] and m1 <= a[3]:
		score.append('NO')
	elif m2 <= a[0] and m2 <= a[1]:
		score.append('NO')
	else:
		score.append('YES')
for i in score:
	print(i)


import sys
input = sys.stdin.readline

def solve():
	a = list(map(int, input().split()))
	b = [max(a[0], a[1]), max(a[2], a[3])]
	print(['NO', 'YES'][sorted(b) == sorted(a)[2:]])
for i in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	a = [int(x) for x in input().split()]
	if max(a[0], a[1]) > min(a[2], a[3]) and max(a[2], a[3]) > min(a[0], a[1]):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	b = []
	for i in a:
		b.append(i)
	b.sort()
	if max(a[0], a[1]) == b[len(b) - 1] and max(a[2], a[3]) == b[len(b) - 2]:
		print('YES')
	elif max(a[0], a[1]) == b[len(b) - 2] and max(a[2], a[3]) == b[len(b) - 1]:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(a, b, c, d) = [int(x) for x in input().split(' ')]
	if max(a, b) > min(c, d) and max(c, d) > min(a, b):
		print('YES')
	else:
		print('NO')


for s in [*open(0)][1:]:
	a = (*map(int, s.split()),)
	print('YNEOS'[max(a[:2]) + max(a[2:]) != sum(sorted(a)[2:])::2])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if (max(a, b) == max(a, b, c) or max(a, b) == max(a, b, d)) and (max(c, d) == max(a, c, d) or max(c, d) == max(b, c, d)):
		print('YES')
	else:
		print('NO')


def sol():
	N = int(input())
	pairs = []
	teams = []
	for _ in range(N):
		teams.append([int(x) for x in input().split()])
	for t in range(len(teams)):
		team1 = (teams[t][0], teams[t][1])
		team2 = (teams[t][2], teams[t][3])
		if max(team1) < min(team2) or max(team2) < min(team1):
			print('NO')
		else:
			print('YES')
sol()


def fun(ls):
	(a, b, c, d) = ls
	min1 = min(a, b)
	min2 = min(c, d)
	max1 = max(a, b)
	max2 = max(c, d)
	if min1 > max2 or min2 > max1:
		print('NO')
	else:
		print('YES')
T = int(input())
for i in range(T):
	ls = list(map(int, input().split()))
	fun(ls)


for i in range(int(input())):
	S = list(map(int, input().split()))
	A = S[:2]
	B = S[2:]
	k = sorted(S)
	m = k[-1]
	m1 = k[-2]
	if m in A and m1 in A:
		print('NO')
	elif m in B and m1 in B:
		print('NO')
	else:
		print('YES')


case = int(input())
while case > 0:
	(a, b, c, d) = map(int, input().split())
	if a > b and c > d and (a > d) and (c > b):
		print('YES')
	elif b > a and c > d and (b > d) and (c > a):
		print('YES')
	elif a > b and d > c and (a > c) and (d > b):
		print('YES')
	elif b > a and d > c and (b > c) and (d > a):
		print('YES')
	else:
		print('NO')
	case -= 1


import sys
from sys import stdin
from sys import stdout
try:
	test = sys.stdin.readline()
	test = int(test)
	for z in range(test):
		a = list(map(int, sys.stdin.readline().strip().split()))
		b = []
		for i in a:
			b.append(i)
		b.sort()
		if b[-1] == a[0] or b[-1] == a[1]:
			if b[-2] == a[2] or b[-2] == a[3]:
				sys.stdout.write('YES\n')
			else:
				sys.stdout.write('NO\n')
		if b[-1] == a[2] or b[-1] == a[3]:
			if b[-2] == a[0] or b[-2] == a[1]:
				sys.stdout.write('YES\n')
			else:
				sys.stdout.write('NO\n')
except EOFError:
	pass


def fun(arr):
	a = 0
	b = 0
	if arr[0] <= arr[1]:
		a = arr[1]
	else:
		a = arr[0]
	if arr[2] <= arr[3]:
		b = arr[3]
	else:
		b = arr[2]
	arr.sort(reverse=True)
	if arr[0] == a and arr[1] == b or (arr[0] == b and arr[1] == a):
		return 'YES'
	return 'NO'
for i in range(0, int(input())):
	(a, b, c, d) = [int(x) for x in input().split()]
	print(fun([a, b, c, d]))


import sys
input = sys.stdin.readline

def print(*args, end='\n', sep=' ') -> None:
	sys.stdout.write(sep.join(map(str, args)) + end)

def Solve():
	s = sorted(enumerate(list(map(int, input().split()))), key=lambda x: x[1])
	print('YES' if s[-1][0] > 1 and s[-2][0] <= 1 or (s[-2][0] > 1 and s[-1][0] <= 1) else 'NO')
for t in range(int(input())):
	Solve()


for _ in range(int(input())):
	l = list(map(int, input().split()))
	s = sorted(l)
	if s[2] in l[0:2] and s[3] in l[0:2] or (s[2] in l[2:4] and s[3] in l[2:4]):
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	lis = list(map(int, input().split()))
	if lis[0] > lis[2] and lis[0] > lis[3] and (lis[1] > lis[2]) and (lis[1] > lis[3]):
		print('NO')
	elif lis[2] > lis[0] and lis[2] > lis[1] and (lis[3] > lis[0]) and (lis[3] > lis[1]):
		print('NO')
	else:
		print('YES')


def maximum(a, b):
	if a >= b:
		return a
	else:
		return b
n = int(input())
for i in range(n):
	inputs = list(map(int, input().split()))
	r1_w1 = maximum(inputs[0], inputs[1])
	r1_w2 = maximum(inputs[2], inputs[3])
	inputs.sort(reverse=True)
	if r1_w1 == inputs[0] and r1_w2 == inputs[1]:
		print('YES')
	elif r1_w1 == inputs[1] and r1_w2 == inputs[0]:
		print('YES')
	else:
		print('NO')


t = int(input())
answer = []
for i in range(t):
	s = list(map(int, input().split(' ')))
	if max(s[0], s[1]) < min(s[2], s[3]) or min(s[0], s[1]) > max(s[2], s[3]):
		answer.append('NO')
	else:
		answer.append('YES')
for i in answer:
	print(i)


t = int(input())
lan = []
for _ in range(t):
	x = list(map(int, input().split()))
	ln = []
	max_1 = max(x[0], x[1])
	max_2 = max(x[2], x[3])
	x.sort()
	ln.append(x[2])
	ln.append(x[3])
	if max_1 in ln and max_2 in ln:
		lan.append('YES')
	else:
		lan.append('NO')
print(*lan, sep='\n')


for _ in range(int(input())):
	si = list(map(int, input().split()))
	ai = sorted(si)
	if max(si[0], si[1]) == ai[-1] and max(si[2], si[3]) == ai[-2]:
		print('YES')
	elif max(si[0], si[1]) == ai[-2] and max(si[2], si[3]) == ai[-1]:
		print('YES')
	else:
		print('NO')


def Fair(arr):
	maximum_a = max(arr)
	newa = list(arr)
	player_list = [max(arr[0], arr[1]), max(arr[2], arr[3])]
	for i in range(len(newa)):
		if newa[i] == maximum_a:
			del newa[i]
			break
	maximum_b = max(newa)
	if maximum_a in player_list:
		if maximum_b in player_list:
			return 'YES'
		else:
			return 'NO'
	else:
		return 'NO'
t = int(input().strip())
for i in range(t):
	object_a = input().split(' ')
	for i in range(len(object_a)):
		object_a[i] = int(object_a[i])
	print(Fair(object_a))


def check(s):
	if min(s[0], s[1]) > max(s[2], s[3]):
		return False
	if max(s[0], s[1]) < min(s[2], s[3]):
		return False
	return True
t = int(input())
for it in range(t):
	s = [int(tmp) for tmp in input().split()]
	if check(s):
		print('YES')
	else:
		print('NO')


matches = []
yes_no = []
tests = int(input())
if tests > 10 ** 4 or tests < 1:
	exit()
for i in range(tests):
	x = list(map(int, input().split()))
	if len(x) != 4:
		exit()
	else:
		matches.append(x)
for game in matches:
	(first, second, third, fourth) = game
	finalists = (max(first, second), max(third, fourth))
	max1 = max(game)
	if max1 > 100:
		exit()
	if min(game) < 1:
		exit()
	game.remove(max1)
	max2 = max(game)
	if max1 in finalists and max2 in finalists:
		yes_no.append('YES')
	else:
		yes_no.append('NO')
print('\n'.join(yes_no))


import sys
from os import path
import math
import time
from collections import defaultdict
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)
MOD = 10 ** 9 + 7
INT_MAX = 10 ** 9
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def test_case():
	t = int(input())
	for _ in range(t):
		s = list(map(int, input().split()))
		if (s[0] > s[2] and s[0] > s[3]) and (s[1] > s[2] and s[1] > s[3]):
			print('NO')
		elif (s[2] > s[0] and s[2] > s[1]) and (s[3] > s[0] and s[3] > s[1]):
			print('NO')
		else:
			print('YES')
test_case()


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	x1 = max(a, b)
	x2 = max(c, d)
	if x1 > min(c, d) and x2 > min(a, b):
		print('YES')
	else:
		print('NO')


try:
	t = int(input())
	while t > 0:
		l = list(map(int, input().split()))
		z = l.copy()
		z.sort()
		first = z[-1]
		second = z[-2]
		m = []
		i = 3
		while i > 0:
			if l[i] > l[i - 1]:
				m.append(l[i])
			else:
				m.append(l[i - 1])
			i -= 2
		if first in m and second in m:
			print('YES')
		else:
			print('NO')
			i -= 2
		t -= 1
except:
	pass


def main():
	(S1, S2, S3, S4) = map(int, input().split())
	A = {S1, S2}
	B = {S3, S4}
	(T1, T2, _, _) = sorted([S1, S2, S3, S4])
	if {T1, T2} == A or {T1, T2} == B:
		print('NO')
	else:
		print('YES')
T = int(input())
for _ in range(T):
	main()


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	x = max(a, b)
	y = max(c, d)
	z = min(a, b)
	w = min(c, d)
	if min(x, y) > max(z, w):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	s = list(map(int, input().split()))
	w1 = max(s[0], s[1])
	w2 = max(s[2], s[3])
	if w1 > w2:
		bigger = w1
		smaller = w2
	else:
		bigger = w2
		smaller = w1
	s.sort()
	if s[-1] == bigger and s[-2] == smaller:
		print('YES')
	else:
		print('NO')


answer = []

def check(li):
	(one, two, three, four) = li
	if one > two:
		win1 = one
		l1 = two
	else:
		win1 = two
		l1 = one
	if three > four:
		win2 = three
		l2 = four
	else:
		win2 = four
		l2 = three
	if win1 > l2 and win2 > l1:
		return 'YES'
	else:
		return 'NO'
n = int(input())
for _ in range(n):
	t = [int(item) for item in input().split()]
	answer.append(check(t))
for item in answer:
	print(item)


t = int(input())
while t:
	t -= 1
	skills = input().split()
	(min1, max1) = (min(int(skills[0]), int(skills[1])), max(int(skills[0]), int(skills[1])))
	(min2, max2) = (min(int(skills[2]), int(skills[3])), max(int(skills[2]), int(skills[3])))
	if max1 < min2 or max2 < min1:
		print(f'NO')
	else:
		print(f'YES')


t = int(input())
for i in range(t):
	(s1, s2, s3, s4) = input().split(' ')
	s1 = int(s1)
	s2 = int(s2)
	s3 = int(s3)
	s4 = int(s4)
	if s1 > s2 and s2 > s3 and (s2 > s4) or (s2 > s1 and s1 > s3 and (s1 > s4)) or (s3 > s4 and s4 > s1 and (s4 > s2)) or (s4 > s3 and s3 > s1 and (s3 > s2)):
		print('NO')
	else:
		print('YES')


t = int(input())
results = []
for i in range(t):
	temps = list(map(int, input().split()))
	if min(temps[0], temps[1]) > max(temps[2], temps[3]) or min(temps[2], temps[3]) > max(temps[0], temps[1]):
		results.append('NO')
	else:
		results.append('YES')
print('\n'.join(results))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	l = [int(i) for i in sys.stdin.readline().split()]
	a = [max(l[0:2]), max(l[2:4])]
	l.sort(reverse=True)
	l = l[0:2]
	l.sort(reverse=True)
	a.sort(reverse=True)
	if a == l:
		print('Yes')
	else:
		print('NO')


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from bisect import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def I():
	return int(input())

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

def LI_():
	return [int(i) - 1 for i in input().split()]

def AI():
	return map(int, open(0).read().split())

def S_():
	return input()

def IS():
	return input().split()

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

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	n = random.randint(1, N)
	a = RLI(n, 0, n - 1)
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]

def gcj(c, x):
	print('Case #{0}:'.format(c + 1), x)
show_flg = False
show_flg = True
for i in range(I()):
	a = LI()
	b = sorted(a)
	(x, y) = b[-2:]
	s = set([x, y])
	t = set([max(a[:2]), max(a[2:])])
	Yn(s == t)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	p = arr[:]
	p.sort(reverse=True)
	p = set(p[:-2])
	a = max(arr[0], arr[1])
	b = max(arr[2], arr[3])
	ans = set()
	ans.add(a)
	ans.add(b)
	if ans == p:
		print('YES')
	else:
		print('NO')


from sys import stdin
n = int(stdin.readline())
for _ in range(n):
	data = [int(x) for x in stdin.readline().strip().split()]
	p1_max = max(data[0], data[1])
	p1_min = min(data[0], data[1])
	p2_max = max(data[2], data[3])
	p2_min = min(data[2], data[3])
	if p1_max > p2_min and p2_max > p1_min:
		print('YES')
	else:
		print('NO')


t = int(input())
cases = []
while t > 0:
	cases.append([int(x) for x in input().split(' ')])
	t -= 1
for case in cases:
	if max(case[0], case[1]) < min(case[2], case[3]) or min(case[0], case[1]) > max(case[2], case[3]):
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t = t - 1
	a = list(map(int, input().split()))
	b = sorted(a)
	maxx = b[-1]
	maxx2 = b[-2]
	if maxx in a[0:2]:
		if maxx2 in a[2:4]:
			print('YES')
		else:
			print('NO')
	elif maxx2 in a[0:2]:
		if maxx in a[2:4]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def solve():
	(s1, s2, s3, s4) = map(int, input().split())
	arr = sorted([s1, s2, s3, s4])
	(a, b) = (max(s1, s2), max(s3, s4))
	(a, b) = (max(a, b), min(a, b))
	return 'YES' if a == arr[-1] and b == arr[-2] else 'NO'
for _ in range(int(input())):
	print(solve())


def check():
	d = 4
	m = [int(d) for d in input().split(' ')]
	j = []
	j.append(max(m[0:2]))
	j.append(max(m[2:]))
	m.sort()
	j.sort()
	for i in range(2):
		m.pop(0)
	if m == j:
		return 'YES'
	else:
		return 'NO'
c = int(input())
d = []
for i in range(c):
	d.append(check())
for j in d:
	print(j)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	l = list(map(int, input().split()))
	y = sorted(l)
	a = l.index(y[-1])
	b = l.index(y[-2])
	if abs(a - b) > 1:
		print('YES')
	elif a == 1 and b == 2:
		print('YES')
	elif a == 2 and b == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	thr = max(a[0], a[1])
	fr = max(a[2], a[3])
	a.sort()
	mini = min(thr, fr)
	maxi = max(thr, fr)
	if mini == a[2] and maxi == a[3]:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
import math
from itertools import accumulate
input = sys.stdin.readline

def inpit():
	return int(input())

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

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

def inpspit():
	return map(int, input().split())
pow = math.pow
fl = math.floor
ceil = math.ceil
dis = math.hypot

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

def cumulativeSum(input):
	return list(accumulate(input))
t = inpit()
for i in range(t):
	(a, b, c, d) = inpspit()
	if max(a, b) < min(d, c) or max(d, c) < min(a, b):
		print('NO')
	else:
		print('YES')


T = int(input())
L = ['YES'] * T
for i in range(0, T):
	s = [int(x) for x in input().split()]
	max1 = max(s)
	ind1 = s.index(max1)
	s[ind1] = 0
	max2 = max(s)
	ind2 = s.index(max2)
	if ind1 <= 1 and ind2 <= 1:
		L[i] = 'NO'
	if ind1 > 1 and ind2 > 1:
		L[i] = 'NO'
for string in L:
	print(string)


t = int(input())
for _ in range(t):
	s = [int(j) for j in input().split()]
	s12 = max(s[0], s[1])
	s34 = max(s[2], s[3])
	s.sort(reverse=True)
	if max(s12, s34) == s[0] and min(s12, s34) == s[1]:
		print('YES')
	else:
		print('NO')


from sys import stdin
lst = list(map(int, stdin.read().split()))
_s = 0

def inp(n=1):
	global _s
	ret = lst[_s:_s + n]
	_s += n
	return ret

def inp1():
	return inp()[0]
t = inp1()
for _ in range(t):
	p = inp(4)
	ps = sorted(p.copy())
	mx1 = ps[-1]
	mx2 = ps[-2]
	if p.index(mx1) + p.index(mx2) == 5 or p.index(mx1) + p.index(mx2) == 1:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	players = [int(i) for i in input().split()]
	fair_match = list(sorted(players, reverse=True))[:2]
	real_match = sorted([max(players[0], players[1]), max(players[2], players[3])], reverse=True)
	if fair_match == real_match:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = [int(c) for c in input().split()]
	if max(a[1], a[0]) < min(a[3], a[2]):
		print('NO')
	elif min(a[1], a[0]) > max(a[3], a[2]):
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	res1 = max(a[0], a[1])
	res2 = max(a[2], a[3])
	a.sort()
	mn = min(res1, res2)
	if mn == a[2]:
		print('YES')
	else:
		print('NO')


t = int(input())
cases = [list(map(int, input().split())) for _ in range(t)]
for s in cases:
	a = sorted([max(s[0], s[1]), max(s[2], s[3])])
	b = sorted(s)[2:]
	if a == b:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	first = max(a, b)
	second = max(c, d)
	f = sorted([a, b, c, d])
	if first > max(f[0], f[1]) and second > max(f[0], f[1]):
		print('YES')
	else:
		print('NO')


test = int(input())
for i in range(test):
	(a, b, c, d) = map(int, input().split())
	round1 = max(a, b)
	round2 = max(c, d)
	e = sorted([round1, round2])
	x = sorted([a, b, c, d])
	print('YES' if e[0] == x[2] and e[1] == x[3] else 'NO')


import math
import string
import random
import sys
from random import randrange
from collections import deque
from collections import defaultdict
from bisect import bisect, bisect_right, bisect_left

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
for _ in range(int(input())):
	s = mdata()
	p1 = s[0] if s[0] > s[1] else s[1]
	p2 = s[2] if s[2] > s[3] else s[3]
	s.sort()
	if max(p1, p2) == s[-1] and min(p1, p2) == s[-2]:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for i in range(t):
		solve()

def solve():
	a = list(map(int, input().split()))
	winners = [max(a[0], a[1]), max(a[2], a[3])]
	a.sort()
	winners.sort()
	if [a[-2], a[-1]] != winners:
		print('NO')
	else:
		print('YES')
main()


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	(win1, f1) = (max(l[0], l[1]), min(l[0], l[1]))
	(win2, f2) = (max(l[2], l[3]), min(l[2], l[3]))
	if f1 > win2 or f2 > win1:
		print('NO')
	else:
		print('YES')


from sys import stdin

def solve():
	seq = stdin.readline().split()
	for i in range(4):
		seq[i] = int(seq[i])
	l = seq[:]
	l.sort(reverse=True)
	l1 = l[:2]
	if max(seq[0], seq[1]) in l1 and max(seq[2], seq[3]) in l1:
		print('YES')
	else:
		print('NO')
t = int(stdin.readline().strip())
for _ in range(t):
	solve()


def solve():
	(player_1, player_2, player_3, player_4) = input().split()
	if min(int(player_1), int(player_2)) < max(int(player_3), int(player_4)) and max(int(player_1), int(player_2)) > min(int(player_3), int(player_4)):
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(0, t):
	solve()


for i in range(int(input())):
	x = list(map(int, input().split()))
	l = sorted(x)
	m = l[3]
	n = l[2]
	if m == x[0] and n == x[3]:
		print('YES')
	elif m == x[0] and n == x[2]:
		print('YES')
	elif m == x[1] and n == x[2]:
		print('YES')
	elif m == x[1] and n == x[3]:
		print('YES')
	elif n == x[0] and m == x[3]:
		print('YES')
	elif n == x[0] and m == x[2]:
		print('YES')
	elif n == x[1] and m == x[2]:
		print('YES')
	elif n == x[1] and m == x[3]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	m = max(l)
	i = l.index(m)
	l[i] = -1
	m2 = max(l)
	j = l.index(m2)
	if i + j == 1 or i + j == 5:
		print('NO')
	else:
		print('YES')


def foo(arr):
	m1 = max(arr[:2])
	m2 = max(arr[2:])
	if m1 > min(arr[2:]) and m2 > min(arr[:2]):
		return 'YES'
	return 'NO'

def main():
	t = int(input())
	for i in range(t):
		arr = list(map(int, input().split()))
		print(foo(arr))
main()


import sys
inputlines = sys.stdin.readlines()
number_of_testcases = int(inputlines[0])
for i in range(number_of_testcases):
	(s1, s2, s3, s4) = list(map(int, inputlines[i + 1].split(' ')))
	maxs3s4 = max(s3, s4)
	mins3s4 = min(s3, s4)
	if s1 > maxs3s4 and s2 > maxs3s4 or (s1 < mins3s4 and s2 < mins3s4):
		print('NO')
	else:
		print('YES')


import sys

def main():
	numTest: int = int(sys.stdin.readline().split()[0])
	for i in range(0, numTest):
		A = [int(x) for x in sys.stdin.readline().split()]
		max = -1
		max2 = -1
		maxIdx = -1
		max2Idx = -1
		for (idx, skill) in enumerate(A):
			if skill > max:
				max2 = max
				max2Idx = maxIdx
				max = skill
				maxIdx = idx
			elif skill > max2:
				max2 = skill
				max2Idx = idx
		if abs(maxIdx - max2Idx) >= 2 or (maxIdx == 1 and max2Idx == 2) or (maxIdx == 2 and max2Idx == 1):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for i in range(t):
	lst = list(map(int, input().split()))
	lst2 = sorted(lst)
	if lst2[-1] in lst[0:2] and lst2[-2] in lst[2:4]:
		print('YES')
	elif lst2[-1] in lst[2:4] and lst2[-2] in lst[0:2]:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	m = max(a, b, c, d)
	second_max = sorted([a, b, c, d])[-2]
	first = max(a, b)
	second = max(c, d)
	if first in [m, second_max] and second in [m, second_max]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = list(map(int, input().split()))
	k = sorted(s)
	cnt = k[-1] + k[-2]
	if s[0] + s[1] == cnt or s[2] + s[3] == cnt:
		print('NO')
	else:
		print('YES')


t = int(input())
for x in range(t):
	s = list(map(int, input().split()))
	lista = []
	lista.append(sorted(s))
	prawie = lista[0][2]
	najwieksza = lista[0][3]
	if prawie == s[0] and najwieksza == s[1] or (prawie == s[1] and najwieksza == s[0]) or (prawie == s[2] and najwieksza == s[3]) or (prawie == s[3] and najwieksza == s[2]):
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	lst = list(map(int, input().split()))
	k = lst.copy()
	k.sort()
	s3 = k[2]
	s4 = k[3]
	first = max(lst[0], lst[1])
	second = max(lst[2], lst[3])
	if first == s3 and second == s4 or (first == s4 and second == s3):
		print('YES')
	else:
		print('NO')


def solve(args):
	winners = [max(args[0], args[1]), max(args[2], args[3])]
	maxes = []
	mx = 0
	for j in range(0, 4):
		if args[j] > mx:
			mx = args[j]
	maxes.append(mx)
	mx = 0
	for j in range(0, 4):
		if args[j] > mx and args[j] < maxes[0]:
			mx = args[j]
	maxes.append(mx)
	if winners[0] in maxes and winners[1] in maxes:
		print('YES')
	else:
		print('NO')
n = int(input())
args = []
for i in range(0, n):
	args.append([])
	ns = input().split(' ')
	for j in range(0, 4):
		args[i].append(int(ns[j]))
for i in range(0, n):
	solve(args[i])


t = int(input())
for i in range(t):
	e = [int(i) for i in input().split()][:4]
	e1 = e[:2]
	e2 = e[2:4]
	k = max(e)
	e.remove(k)
	k1 = max(e)
	if k in e1 and k1 in e2 or (k in e2 and k1 in e1):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	m = l[:]
	l.sort(reverse=True)
	a = l[0]
	b = l[1]
	p = max(m[0], m[1])
	q = max(m[2], m[3])
	if p == a and q == b or (p == b and q == a):
		print('YES')
	else:
		print('NO')


def solve(s):
	l = max(s[0], s[1])
	p = max(s[2], s[3])
	if s[2] > l and s[3] > l or (s[1] > p and s[0] > p):
		print('NO')
	else:
		print('YES')
n = int(input())
for i in range(n):
	s = list(map(int, input().split()))
	solve(s)


from collections import defaultdict, Counter
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

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

def stf():
	return file.readline().strip()

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

def readf():
	return list(map(int, file.readline().strip().split()))
ans_ = []

def solve():
	for _ in range(nin()):
		(a, b, c, d) = read()
		if sorted([max(a, b), max(c, d)]) == sorted([a, b, c, d])[2:]:
			ans_.append('YES')
		else:
			ans_.append('NO')
solve()
for i in ans_:
	print(i)


for s in [*open(0)][1:]:
	(a, b, c, d) = map(int, s.split())
	print('YNEOS'[min(a, b) > max(c, d) or min(c, d) > max(a, b)::2])


def solve():
	(q, w, e, r) = [int(i) for i in input().split()]
	if max(q, w) < e and max(q, w) < r or (max(e, r) < q and max(e, r) < w):
		return 'NO'
	return 'YES'
t = int(input())
ans = []
while t:
	ans.append(str(solve()))
	t -= 1
print('\n'.join(ans))


for _ in range(int(input())):
	a = list(map(int, input().split()))
	c = [max(a[0], a[1]), max(a[2], a[3])]
	d = [i for i in a]
	d.sort()
	if d[-1] in c and d[-2] in c:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(0, n):
	my_list = input().split()
	my_list = [int(item) for item in my_list]
	a = my_list[0]
	b = my_list[1]
	c = my_list[2]
	d = my_list[3]
	if a > b and a > c and (a > d):
		if b > c and b > d:
			print('NO')
		else:
			print('YES')
	elif b > a and b > c and (b > d):
		if a > c and a > d:
			print('NO')
		else:
			print('YES')
	elif c > b and c > a and (c > d):
		if d > a and d > b:
			print('NO')
		else:
			print('YES')
	elif d > b and d > a and (d > c):
		if c > a and c > b:
			print('NO')
		else:
			print('YES')


import sys
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input().rstrip())
	for i in range(tests):
		list_ = list(map(int, input().rstrip().split()))
		winner_1 = 0
		if list_[0] < list_[1]:
			winner_1 += list_[1]
		else:
			winner_1 += list_[0]
		winner_2 = 0
		if list_[2] < list_[3]:
			winner_2 += list_[3]
		else:
			winner_2 += list_[2]
		list_ = sorted(list_, reverse=True)
		winners_ = set()
		winners_.add(list_[0])
		winners_.add(list_[1])
		if winner_1 in winners_ and winner_2 in winners_:
			output('YES')
		else:
			output('NO')
		output('\n')
main()


def team(listo: list):
	team1 = listo[:2]
	team2 = listo[-2:]
	team1.sort(reverse=True)
	team2.sort(reverse=True)
	boro1 = team1[0]
	boro2 = team2[0]
	listo.remove(boro1)
	listo.remove(boro2)
	if boro1 > boro2:
		choto = boro2
	else:
		choto = boro1
	return choto
caseNo = int(input())
for i in range(caseNo):
	iq = [int(x) for x in input().split(' ')]
	choto = team(iq)
	hbe_na = False
	for i in iq:
		if i > choto:
			hbe_na = True
	if hbe_na == True:
		print('NO')
	else:
		print('YES')


import sys

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

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

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

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

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

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

def get_print(x):
	sys.stdout.write(x + '\n')

def get_print_int_same(x):
	sys.stdout.write(str(x) + ' ')

def get_print_same(x):
	sys.stdout.write(x + ' ')
from sys import maxsize

def solve():
	for _ in range(get_int()):
		arr = get_list()
		w1 = max(arr[0], arr[1])
		w2 = max(arr[2], arr[3])
		arr.sort(reverse=True)
		if arr[0] == w1 and arr[1] == w2 or (arr[0] == w2 and arr[1] == w1):
			get_print('YES')
		else:
			get_print('NO')
solve()


t = int(input())
while t > 0:
	t -= 1
	a = list(map(int, input().split()))
	b = sorted(a)
	m1 = b[-1]
	m2 = b[-2]
	win1 = max(a[0], a[1])
	win2 = max(a[2], a[3])
	if (win1 == m1 or win1 == m2) and (win2 == m1 or win2 == m2):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	arr = list(map(int, input().split()))
	sortedArr = arr.copy()
	sortedArr.sort()
	(b1, b2) = (sortedArr[3], sortedArr[2])
	if arr.index(b1) < 2 and arr.index(b2) < 2 or (arr.index(b1) >= 2 and arr.index(b2) >= 2):
		print('NO')
	else:
		print('YES')


def fair(a, b):
	max = 0
	min = 0
	if a < b:
		max = b
		min = a
	else:
		max = a
		min = b
	return (max, min)
n = int(input())
result = []
for i in range(n):
	skill = list(map(int, input().split()))
	(max1, min1) = fair(skill[0], skill[1])
	(max2, min2) = fair(skill[2], skill[3])
	if max1 < min2 or min1 > max2:
		result.append('NO')
	else:
		result.append('YES')
for i in range(n):
	print(result[i])


import sys

def read_ints():
	return [int(i) for i in sys.stdin.readline().strip().split()]

def read_int():
	return int(sys.stdin.readline().strip())
t = read_int()
for i in range(t):
	ss = read_ints()
	winners = {max(ss[0:2]), max(ss[2:])}
	ss.sort()
	best = set(ss[2:])
	if best == winners:
		print('YES')
	else:
		print('NO')


t = int(input())
k = []
for _ in range(t):
	a = list(map(int, input().split()))
	k.append(a)
for i in k:
	(k1, k2) = (i[:2], i[2:])
	if max(k1) > min(k2) and max(k2) > min(k1):
		print('YES')
	else:
		print('NO')


import math
from collections import defaultdict, Counter
import sys

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')

def ceil(a, b):
	return (a + b - 1) // b
for _ in range(ri()):
	(a, b, c, d) = ria()
	l = [a, b, c, d]
	x = max(a, b)
	y = max(c, d)
	z = [x, y]
	z.sort()
	l.sort()
	if z == l[2:]:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
from collections import deque
from sys import stdout
for _ in range(int(input())):
	s = [int(i) for i in input().split()]
	s1 = max(s[0], s[1])
	s2 = max(s[2], s[3])
	if s1 > s2:
		(s1, s2) = (s2, s1)
	s.sort()
	if s1 == s[-2] and s2 == s[-1]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	li = list(map(int, input().split()))
	(mx1, mx2) = (-10000000, -1000000000)
	for i in li:
		if mx1 < i:
			mx1 = i
	for i in li:
		if mx2 < i and i != mx1:
			mx2 = i
	(temp1, temp2) = (max(li[0], li[1]), max(li[2], li[3]))
	if temp1 in [mx1, mx2] and temp2 in [mx1, mx2]:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	m1 = max(a[:2])
	m2 = max(a[2:])
	a.sort()
	high = a[2:]
	if m1 in high and m2 in high:
		print('YES')
	else:
		print('NO')


n = int(input())
ans = []
for i in range(n):
	ssss = input().split()
	s1 = int(ssss[0])
	s2 = int(ssss[1])
	s3 = int(ssss[2])
	s4 = int(ssss[3])
	if s1 > s3 and s1 > s4 and (s2 > s3) and (s2 > s4):
		ans.append('NO')
	elif s3 > s1 and s3 > s2 and (s4 > s1) and (s4 > s2):
		ans.append('NO')
	else:
		ans.append('YES')
for i in ans:
	print(i)


for i in range(int(input())):
	d = [int(d) for d in input().split()]
	max_first = max(d)
	max_second = 0
	for i in d:
		if i > max_second and i != max_first:
			max_second = i
	if max_first in d[:2] and max_second in d[:2] or (max_first in d[2:] and max_second in d[2:]):
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	s = tuple((int(x) for x in input().split()))
	maxa = maxb = -1
	inmaxa = -1
	for j in range(4):
		if s[j] > maxa:
			maxa = s[j]
			inmaxa = j
	for j in range(4):
		if s[j] > maxb and j != inmaxa:
			maxb = s[j]
	win = (max(s[0], s[1]), max(s[2], s[3]))
	if win[0] == maxa and win[1] == maxb or (win[0] == maxb and win[1] == maxa):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(0, n):
	(a, b, c, d) = map(int, input().split())
	w1 = max(a, b)
	w2 = max(c, d)
	if w1 < c and w1 < d:
		print('NO')
	elif w2 < a and w2 < b:
		print('NO')
	else:
		print('YES')


import sys
from sys import stdout
import io, os
P = lambda : list(map(int, input().split()))
from math import factorial as f
from collections import deque, defaultdict as dd
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge
from random import randint, choice, sample
import time
mod = 10 ** 9 + 7
a = ord('a')
start = time.time()

def fast_exp(x, exp):
	ans = 1
	base = x
	while exp:
		if exp & 1:
			ans *= base
		base *= base
		base %= mod
		ans %= mod
		exp >>= 1
	return ans

def countBits(n):
	count = 0
	while n:
		count += n & 1
		n >>= 1
	return count

def submasks(n):
	org = n
	while n:
		yield n
		n = n - 1 & org

def solve():
	nums = (a, b, c, d) = P()
	if sorted(nums)[2:] == sorted([max(a, b), max(c, d)]):
		print('YES')
	else:
		print('NO')
tc = int(input())
for t in range(1, tc + 1):
	solve()


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	m1 = max(a, b)
	m2 = min(a, b)
	m3 = min(c, d)
	m4 = max(c, d)
	if m1 < m3 or m2 > m4:
		print('No')
	else:
		print('Yes')


for s in [*open(0)][1:]:
	arr = list(map(int, s.split()))
	(a, b, c, d) = arr.copy()
	(x, y) = [max(a, b), max(c, d)]
	arr = [arr.pop(arr.index(max(arr))), arr.pop(arr.index(max(arr)))]
	if x in arr and y in arr:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
(input, print) = (stdin.readline, stdout.write)
from math import *

def main():
	for _ in range(int(input())):
		a = list(map(int, input().split()))
		b = a.copy()
		b.sort()
		if b[0] == a[0] and b[1] == a[2] or (b[0] == a[1] and b[1] == a[2]) or (b[0] == a[0] and b[1] == a[3]) or (b[0] == a[1] and b[1] == a[3]) or (b[0] == a[2] and b[1] == a[0]) or (b[0] == a[3] and b[1] == a[0]) or (b[0] == a[2] and b[1] == a[1]) or (b[0] == a[3] and b[1] == a[1]):
			print('YES\n')
		else:
			print('NO\n')
main()


t = int(input())
while t > 0:
	a = list(map(int, input().split()))
	b = [max(a[0], a[1]), max(a[2], a[3])]
	a.sort()
	b.sort()
	a = a[2:]
	if a == b:
		print('YES')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	(x, y, u, v) = map(int, input().split())
	print('YES' if sorted([max(x, y), max(u, v)]) == sorted([x, y, u, v])[2:] else 'NO')


for i in range(int(input())):
	a = list(map(int, input().split()))
	temp = a[:]
	a.sort()
	m1 = a[3]
	m2 = a[2]
	b = []
	b.append(m1)
	b.append(m2)
	b.sort()
	c = []
	num1 = max(temp[0], temp[1])
	num2 = max(temp[3], temp[2])
	c.append(num1)
	c.append(num2)
	c.sort()
	if b == c:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = list(map(int, input().split()))
	p1 = max(s[0], s[1])
	p2 = max(s[2], s[3])
	s.sort()
	if p1 == s[3] or p1 == s[2]:
		if p2 == s[3] or p2 == s[2]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from math import floor, ceil, sqrt, factorial, inf
from collections import Counter, deque

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

def get_int():
	return int(input())

def get_charlist():
	return list(input())
for t in range(get_int()):
	s = get_list()
	(s1, s2, s3, s4) = s
	s.sort(reverse=True)
	(w1, w2, *w) = s
	if s1 > s2:
		ww1 = s1
	else:
		ww1 = s2
	if s3 > s4:
		ww2 = s3
	else:
		ww2 = s4
	if ww1 < ww2:
		(ww1, ww2) = (ww2, ww1)
	if ww1 == w1 and ww2 == w2:
		print('YES')
	else:
		print('NO')


t = int(input())
A = []
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	if a > b and a > d and (c > b) and (c > d):
		ans = 'YES'
	elif a > b and a > c and (d > b) and (d > c):
		ans = 'YES'
	elif b > a and b > d and (c > a) and (c > d):
		ans = 'YES'
	elif b > a and b > c and (d > a) and (d > c):
		ans = 'YES'
	else:
		ans = 'NO'
	A.append(ans)
for i in A:
	print(i)


for i in range(int(input())):
	no = False
	sample = list(map(int, input().split()))
	copy = list(sample)
	copy.sort(reverse=True)
	copy = copy[0:int(len(sample) / 2)]
	for j in range(0, len(sample), 2):
		if max(sample[j], sample[j + 1]) not in copy:
			no = True
			break
	if no:
		print('No')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = list(map(int, input().strip().split()))[:4]
	if max(s[0], s[1]) > min(s[2], s[3]) and max(s[2], s[3]) > min(s[0], s[1]):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	skills = list(map(int, input().split()))
	if max(skills[:2]) > min(skills[2:]) and max(skills[2:]) > min(skills[:2]):
		print('YES')
	else:
		print('NO')


import sys

def turnir(x: list) -> str:
	maxl = max(x[0], x[1])
	minl = min(x[0], x[1])
	maxr = max(x[2], x[3])
	minr = min(x[2], x[3])
	if maxl >= minr and maxr >= minl:
		return 'YES'
	else:
		return 'NO'

def main():
	n = int(sys.stdin.readline())
	x = [0] * 4
	for _ in range(n):
		x = list(map(int, sys.stdin.readline().split()))
		print(turnir(x))
main()


for t in range(int(input())):
	l = list(map(int, input().split()))
	s1 = l[0]
	s2 = l[1]
	s3 = l[2]
	s4 = l[3]
	l.sort()
	one = 0
	two = 0
	if s1 > s2:
		one = s1
	else:
		one = s2
	if s3 > s4:
		two = s3
	else:
		two = s4
	if one + two == l[-1] + l[-2]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	q = []
	if l[0] > l[1]:
		q.append(l[0])
	elif l[1] > l[0]:
		q.append(l[1])
	if l[2] > l[3]:
		q.append(l[2])
	elif l[2] < l[3]:
		q.append(l[3])
	q.sort()
	l.sort()
	a = l[2:4]
	if a == q:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	l = [a, b, c, d]
	l.sort()
	p = max(a, b)
	q = max(c, d)
	if (p == l[-1] or p == l[-2]) and (q == l[-1] or q == l[-2]):
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	ans = ''
	for _ in range(n):
		skills = list(map(int, input().split(' ')))
		if skills[0] > skills[1]:
			max1index = 0
			max2index = 1
		else:
			max1index = 1
			max2index = 0
		for (index, value) in enumerate(skills):
			if index in [0, 1]:
				continue
			if value > skills[max1index]:
				max2index = max1index
				max1index = index
			elif value > skills[max2index]:
				max2index = index
		middle = 1
		if max1index <= middle and max2index <= middle or (max1index > middle and max2index > middle):
			ans += 'NO\n'
		else:
			ans += 'YES\n'
	print(ans)
main()


t = int(input())
while t > 0:
	t -= 1
	s = [int(i) for i in input().split()]
	a1 = min(s[0], s[1])
	b1 = max(s[0], s[1])
	a2 = min(s[2], s[3])
	b2 = max(s[2], s[3])
	if a1 > b2 or b1 < a2:
		print('NO')
	else:
		print('YES')


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())
ro = lambda : int(input())

def solve():
	A = list(ri())
	fst = snd = -inf
	for x in A:
		if x > fst:
			(fst, snd) = (x, fst)
		elif x > snd:
			snd = x
	half = sorted(A[:2])
	half2 = sorted(A[2:])
	if half == [snd, fst] or half2 == [snd, fst]:
		print('NO')
	else:
		print('YES')
t = 1
t = int(input())
while t:
	t -= 1
	solve()


from sys import stdin

def calculate(a, b, c, d):
	if max(a, b) > min(c, d) and max(c, d) > min(a, b):
		return 'YES'
	return 'NO'
t = int(stdin.readline().strip())
for _ in range(t):
	(a, b, c, d) = map(int, stdin.readline().strip().split())
	print(calculate(a, b, c, d))


T = int(input())
ans = []
for _ in range(T):
	a = [int(k) for k in input().split()]
	a1 = [a[0], a[1]]
	a2 = [a[2], a[3]]
	a.sort()
	if a[3] in a1 and a[2] in a2 or (a[3] in a2 and a[2] in a1):
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


for tc in range(int(input())):
	(a1, a2, b1, b2) = list(map(int, input().strip().split()))[:4]
	a = max(a1, a2)
	b = max(b1, b2)
	if a < min(b1, b2):
		print('NO')
	elif b < min(a1, a2):
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	first = max(a[0], a[1])
	second = max(a[2], a[3])
	a.sort(reverse=True)
	if (first == a[0] or first == a[1]) and (second == a[0] or second == a[1]):
		print('YES')
	else:
		print('NO')