There is a contest containing 2 problems A and B. 

2 strong participants P and Q participated in the contest and solved both the problems.

P made AC submissions on problems A and B at time instants P_{A} and P_{B} respectively while Q made AC submissions on problems A and B at time instants Q_{A} and Q_{B}.

It is given that the time penalty is the minimum time instant at which a participant has solved both the problems. Also the participant with the lower time penalty will have a better rank.

Determine which participant got the better rank or if there is a TIE.

------ Input Format ------ 

- The first line will contain T, number of test cases. Then the test cases follow.
- Each test case contains a single line of input, four integers P_{A}, P_{B}, Q_{A}, Q_{B}.

------ Output Format ------ 

For each test case, output P if P got a better rank, Q if Q got a better rank, TIE otherwise.

Note that output is case-insensitive i.e. P and p both are considered the same.

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$1 ≤ P_{A}, P_{B}, Q_{A}, Q_{B} ≤ 100$

----- Sample Input 1 ------ 
4
5 10 2 12
10 30 15 15
20 8 4 20
6 6 6 6

----- Sample Output 1 ------ 
P
Q
TIE
TIE

----- explanation 1 ------ 
Test Case $1$: 
- Time penalty incurred by participant $P = 10$. 
- Time penalty incurred by participant $Q = 12$.

Since $10 < 12$, $P$ gets a better rank.

Test Case $2$: 
- Time penalty incurred by participant $P = 30$. 
- Time penalty incurred by participant $Q = 15$. 

Since $15 < 30$, $Q$ gets a better rank.

Test Case $3$: 
- Time penalty incurred by participant $P = 20$. 
- Time penalty incurred by participant $Q = 20$. 

Since $20 = 20$, $P$ and $Q$ gets a same rank (TIE).

Test Case $4$: 
- Time penalty incurred by participant $P = 6$. 
- Time penalty incurred by participant $Q = 6$. 

Since $6 = 6$, $P$ and $Q$ gets a same rank (TIE).

Source: codechef | Difficulty: EASY


Solutions:
t = int(input())
for i in range(t):
	(x, y, z, n) = map(int, input().split())
	x1 = max(x, y)
	x2 = max(z, n)
	if x1 < x2:
		print('P')
	elif x1 > x2:
		print('Q')
	else:
		print('TIE')


for _ in range(int(input())):
	(pa, pb, qa, qb) = map(int, input().split())
	tp = max(pa, pb)
	tq = max(qa, qb)
	print('P' if tp < tq else 'TIE' if tp == tq else 'Q')


t = int(input())
for i in range(t):
	(pa, pb, qa, qb) = map(int, input().split())
	p = max(pa, pb)
	q = max(qa, qb)
	if p > q:
		print('Q')
	elif p == q:
		print('TIE')
	else:
		print('P')


t = int(input())
while t > 0:
	(pa, pb, qa, qb) = map(int, input().split())
	print('P' if max(pa, pb) < max(qa, qb) else 'TIE' if max(pa, pb) == max(qa, qb) else 'Q')
	t -= 1


T = int(input())
for t in range(T):
	(Pa, Pb, Qa, Qb) = map(int, input().split())
	a = max(Pa, Pb)
	b = max(Qa, Qb)
	if a > b:
		print('Q')
	elif a < b:
		print('P')
	else:
		print('TIE')


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if max(a, b) < max(c, d):
		print('P')
	elif max(a, b) == max(c, d):
		print('TIE')
	else:
		print('Q')


for i in range(int(input())):
	(pa, pb, qa, qb) = map(int, input().split())
	m = max(pa, pb)
	n = max(qa, qb)
	if m < n:
		print('P')
	elif m > n:
		print('Q')
	else:
		print('TIE')


t = int(input())
for i in range(t):
	(a, p, b, q) = list(map(int, input().split()))
	A = max(a, p)
	B = max(b, q)
	if A < B:
		print('P')
	elif A > B:
		print('Q')
	elif A == B:
		print('TIE')


t = int(input())
for i in range(0, t):
	(a, b, c, d) = map(int, input().split(' '))
	if a <= b:
		m = b
	else:
		m = a
	if c <= d:
		n = d
	else:
		n = c
	if m < n:
		print('P')
	elif m > n:
		print('Q')
	else:
		print('TIE')


t = int(input())
for i in range(t):
	(p1, p2, q1, q2) = map(int, input().split())
	P = max(p1, p2)
	Q = max(q1, q2)
	if P < Q:
		print('P')
	elif P > Q:
		print('Q')
	else:
		print('TIE')


T = int(input())
for i in range(T):
	(pa, pb, qa, qb) = map(int, input().split())
	x = max(pa, pb)
	y = max(qa, qb)
	if y > x:
		print('P')
	elif x == y:
		print('TIE')
	else:
		print('Q')


T = int(input())
for i in range(T):
	(Pa, Pb, Qa, Qb) = map(int, input().split())
	X = max(Pa, Pb)
	Y = max(Qa, Qb)
	if X < Y:
		print('P')
	elif X > Y:
		print('Q')
	else:
		print('TIE')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	e = max(a, b)
	f = max(c, d)
	if e == f:
		print('TIE')
	elif e < f:
		print('P')
	else:
		print('Q')


t = int(input())
for i in range(t):
	(Pa, Pb, Qa, Qb) = map(int, input().split())
	if Pa > Pb:
		r = Pa
	else:
		r = Pb
	if Qa > Qb:
		q = Qa
	else:
		q = Qb
	if r > q:
		print('Q')
	elif r == q:
		print('TIE')
	else:
		print('P')


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	x = max(a, b)
	y = max(c, d)
	if x < y:
		print('P')
	if y < x:
		print('Q')
	if x == y:
		print('TIE')


t = int(input())
for i in range(t):
	(w, x, y, z) = map(int, input().split())
	if max(x, w) == max(y, z):
		print('TIE')
	elif max(x, w) < max(y, z):
		print('P')
	elif max(x, w) > max(y, z):
		print('Q')


for i in range(int(input())):
	(pa, pb, qa, qb) = map(int, input().split())
	a = max(pa, pb)
	b = max(qa, qb)
	if a < b:
		print('P')
	elif b < a:
		print('Q')
	else:
		print('TIE')


for _ in range(int(input())):
	(pa, pb, qa, qb) = map(int, input().split())
	pmax = max(pa, pb)
	qmax = max(qa, qb)
	if pmax > qmax:
		print('Q')
	elif qmax > pmax:
		print('P')
	else:
		print('TIE')


T = int(input())
for i in range(T):
	(a, b, c, d) = map(int, input().split())
	nilai1 = max(a, b)
	nilai2 = max(c, d)
	if nilai1 > nilai2:
		print('Q')
	if nilai1 < nilai2:
		print('P')
	if nilai1 == nilai2:
		print('TIE')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	x = max(a, b)
	y = max(c, d)
	if x > y:
		print('Q')
	elif x < y:
		print('P')
	else:
		print('TIE')


t = int(input())
for i in range(t):
	(a1, a2, b1, b2) = map(int, input().split())
	maxa = max(a1, a2)
	maxb = max(b1, b2)
	if maxa > maxb:
		print('Q')
	elif maxa == maxb:
		print('TIE')
	elif maxb > maxa:
		print('P')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	A = (a, b)
	B = (c, d)
	m = max(a, b)
	n = max(c, d)
	if m == n:
		print('TIE')
	elif m < n:
		print('P')
	elif n < m:
		print('Q')


T = int(input())
while T:
	T -= 1
	(Pa, Pb, Qa, Qb) = map(int, input().split())
	max_P = max(Pa, Pb)
	max_Q = max(Qa, Qb)
	if max_P > max_Q:
		print('Q')
	elif max_P < max_Q:
		print('P')
	else:
		print('TIE')


for i in range(int(input())):
	(p, q, r, s) = map(int, input().split(' '))
	maxp = max(p, q)
	maxq = max(r, s)
	if maxp > maxq:
		print('Q')
	elif maxp < maxq:
		print('P')
	if maxp == maxq:
		print('TIE')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	maxa = max(a, b)
	maxb = max(c, d)
	if maxa > maxb:
		print('Q')
	elif maxa < maxb:
		print('P')
	if maxa == maxb:
		print('TIE')


def winner(P, Q):
	if P == Q:
		print('TIE')
	elif P < Q:
		print('P')
	else:
		print('Q')
t = int(input())
for i in range(t):
	(pa, pb, qa, qb) = map(int, input().split())
	P = max(pa, pb)
	Q = max(qa, qb)
	winner(P, Q)


for _ in range(int(input())):
	(pa, pb, qa, qb) = map(int, input().split())
	tp_p = max(pa, pb)
	tp_q = max(qa, qb)
	if tp_p > tp_q:
		print('Q')
	elif tp_p < tp_q:
		print('P')
	else:
		print('TIE')


n = int(input())
for _ in range(n):
	(pa, pb, qa, qb) = list(map(int, input().split()))
	if max(pa, pb) > max(qa, qb):
		print('Q')
	elif max(pa, pb) < max(qa, qb):
		print('P')
	else:
		print('TIE')


n = int(input())
for i in range(0, n):
	l1 = []
	l2 = []
	(a, b, c, d) = map(int, input().split())
	l1.append(a)
	l1.append(b)
	l2.append(c)
	l2.append(d)
	x = max(l1)
	y = max(l2)
	if x < y:
		print('P')
	elif x > y:
		print('Q')
	else:
		print('TIE')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	if a > b:
		r = a
	else:
		r = b
	if c > d:
		q = c
	else:
		q = d
	if r > q:
		print('Q')
	elif r == q:
		print('TIE')
	else:
		print('P')


T = int(input())
for i in range(T):
	(pa, pb, qa, qb) = map(int, input().split())
	k = max(pa, pb)
	l = max(qa, qb)
	if k < l:
		print('P')
	elif k > l:
		print('Q')
	else:
		print('TIE')


t = int(input())
for _ in range(t):
	(a, b, a2, b2) = list(map(int, input().split()))
	s1 = max(a, b)
	s2 = max(a2, b2)
	if s1 < s2:
		print('P')
	elif s1 > s2:
		print('Q')
	else:
		print('TIE')


for __ in range(int(input())):
	(Pa, Pb, Qa, Qb) = map(int, input().split())
	penalty_P = max(Pa, Pb)
	penalty_Q = max(Qa, Qb)
	if penalty_Q < penalty_P:
		print('Q')
	elif penalty_P < penalty_Q:
		print('P')
	else:
		print('TIE')


t = int(input())
for i in range(t):
	(p1, p2, p3, p4) = map(int, input().split())
	if p1 > p2:
		pen1 = p1
	else:
		pen1 = p2
	if p3 > p4:
		pen2 = p3
	else:
		pen2 = p4
	if pen1 == pen2:
		print('TIE')
	elif pen1 > pen2:
		print('Q')
	else:
		print('P')


t = int(input())
for i in range(t):
	(x, y, z, a) = map(int, input().split(' '))
	b = max(x, y)
	c = max(z, a)
	if b < c:
		print('P')
	elif b > c:
		print('Q')
	else:
		print('TIE')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	maxx = max(a, b)
	maxy = max(c, d)
	if maxx > maxy:
		print('Q')
	elif maxx < maxy:
		print('P')
	if maxx == maxy:
		print('TIE')


t = int(input())
for i in range(0, t):
	(pa, pb, qa, qb) = map(int, input().split())
	l = max(pa, pb)
	j = max(qa, qb)
	if l > j:
		print('Q')
	elif l < j:
		print('P')
	elif l == j:
		print('TIE')


for _ in range(int(input())):
	(p1, p2, q1, q2) = map(int, input().split())
	p = max(p1, p2)
	q = max(q1, q2)
	if p < q:
		print('P')
	elif q < p:
		print('Q')
	else:
		print('TIE')


t = int(input())
for i in range(t):
	(Pa, Pb, Qa, Qb) = map(int, input().split())
	if Pa <= Pb and Qa <= Qb:
		if Pb < Qb:
			print('P')
		elif Pb == Qb:
			print('TIE')
		elif Pb > Qb:
			print('Q')
	elif Pa >= Pb and Qa <= Qb:
		if Pa > Qb:
			print('Q')
		elif Pa == Qb:
			print('TIE')
		elif Pa < Qb:
			print('P')
	elif Pa <= Pb and Qa >= Qb:
		if Pb > Qa:
			print('Q')
		elif Pb == Qa:
			print('TIE')
		elif Pb < Qa:
			print('P')
	elif Pa >= Pb and Qa >= Qb:
		if Pa > Qa:
			print('Q')
		elif Pa == Qa:
			print('TIE')
		elif Pa < Qa:
			print('P')


t = int(input())
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	maxa = max(a, b)
	maxb = max(x, y)
	if maxa < maxb:
		print('P')
	elif maxb < maxa:
		print('Q')
	else:
		print('TIE')