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

Eidi gifts are a tradition in which children receive money from elder relatives during the Eid celebration.

Chef has three children (numbered $1, 2, 3$) and he wants to give them Eidi gifts. The oldest child, Chefu, thinks that a distribution of money is fair only if an older child always receives more money than a younger child; if two children have the same age, they should receive the same amounts of money.

For each valid $i$, the $i$-th child is $A_{i}$ years old and it received $C_{i}$ units of money. Determine whether this distribution of money is fair.

------  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 and only line of each test case contains six space-separated integers $A_{1}$, $A_{2}$, $A_{3}$, $C_{1}$, $C_{2}$ and $C_{3}$.

------  Output ------
For each test case, print a single line containing the string "FAIR" if the distribution is fair or "NOT FAIR" otherwise.

------  Constraints ------
$1 ≤ T ≤ 1,000$
$1 ≤ A_{1}, A_{2}, A_{3} ≤ 17$
$1 ≤ C_{1}, C_{2}, C_{3} ≤ 100$

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

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

5 7 10 10 20 50

5 5 5 20 10 20

10 1 17 5 10 15

3 6 3 8 10 9

8 5 5 50 10 10
----- Sample Output 1 ------ 
FAIR

NOT FAIR

NOT FAIR

NOT FAIR

FAIR
----- explanation 1 ------ 
Example case 2: All children have same age which is 5, but second child got less money than the other children, so it's not fair.

Example case 3: First child is older than second child but he got less money than him, so it's not fair.

Example case 4: First and third children have same age, but didn't get same amount of money,  so it's not fair.

Source: codechef | Difficulty: EASY
Tags: Implementation


Solutions:
for _ in range(int(input())):
	(a, b, c, d, e, f) = map(int, input().split())
	l = [(a, d), (b, e), (c, f)]
	l.sort(key=lambda x: x[0])
	ans = 'FAIR'
	for i in range(2):
		(a, b) = (l[i], l[i + 1])
		if a[0] == b[0]:
			if a[1] != b[1]:
				ans = 'NOT FAIR'
				break
		elif a[1] >= b[1]:
			ans = 'NOT FAIR'
			break
	print(ans)


for _ in range(int(input())):
	(a, b, c, x, y, z) = map(int, input().split())
	dis = [(a, x), (b, y), (c, z)]
	dis.sort(key=lambda x: x[0])
	ans = 'FAIR'
	for i in range(2):
		(a, b) = (dis[i], dis[i + 1])
		if a[0] == b[0]:
			if a[1] != b[1]:
				ans = 'NOT FAIR'
				break
		elif a[1] >= b[1]:
			ans = 'NOT FAIR'
			break
	print(ans)


t = int(input())
for i in range(t):
	(a, b, c, d, e, f) = map(int, input().split())
	if a == b and d == e or (a < b and d < e) or (a > b and d > e):
		if b == c and e == f or (b < c and e < f) or (b > c and e > f):
			if a == c and d == f or (a < c and d < f) or (a > c and d > f):
				print('FAIR')
			else:
				print('NOT FAIR')
		else:
			print('NOT FAIR')
	else:
		print('NOT FAIR')


for _ in range(int(input())):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	a = [a1, a2, a3]
	c = [c1, c2, c3]
	b = 0
	for i in range(len(a)):
		for j in range(i + 1, 3):
			if a[i] > a[j] and c[j] >= c[i]:
				b += 1
			elif a[j] > a[i] and c[i] >= c[j]:
				b += 1
			elif a[i] == a[j] and c[i] != c[j]:
				b += 1
	if b == 0:
		print('FAIR')
	else:
		print('NOT FAIR')


t = int(input())
for t in range(t):
	a = [int(i) for i in input().split()]
	flag = 1
	for i in range(2):
		for j in range(i + 1, 3):
			if a[i] == a[j] and a[i + 3] != a[j + 3]:
				flag = 0
				break
			elif a[i] < a[j] and a[i + 3] >= a[j + 3]:
				flag = 0
				break
			elif a[i] > a[j] and a[i + 3] <= a[j + 3]:
				flag = 0
				break
	if flag == 1:
		print('FAIR')
	else:
		print('NOT FAIR')


T = int(input())
for _ in range(0, T):
	l = list(map(int, input().split()))
	(a, c) = (l[:3], l[3:])
	v = sorted(zip(a, c))
	for i in range(0, 2):
		if v[i][0] < v[i + 1][0] and v[i][1] >= v[i + 1][1]:
			print('NOT FAIR')
			break
		elif v[i][0] == v[i + 1][0] and v[i][1] != v[i + 1][1]:
			print('NOT FAIR')
			break
	else:
		print('FAIR')


for test_ in range(int(input())):
	temp = list(map(int, input().strip().split()))
	(a, c) = (temp[:3], temp[3:])
	val = sorted(zip(a, c))
	for i in range(2):
		if val[i][0] < val[i + 1][0] and val[i][1] >= val[i + 1][1]:
			print('NOT FAIR')
			break
		if val[i][0] == val[i + 1][0] and val[i][1] != val[i + 1][1]:
			print('NOT FAIR')
			break
	else:
		print('FAIR')


for i in range(int(input())):
	l = list(map(int, input().split()))
	sl = []
	mi = l.index(min(l[0:3]))
	xi = l.index(max(l[0:3]))
	if len(set(l[0:3])) == 1 and len(set(l[3:6])) == 1:
		print('FAIR')
	elif len(set(l[0:3])) == 2 and len(set(l[3:6])) == 2:
		for i in range(3):
			if [l[i], l[i + 3]] not in sl:
				sl.append([l[i], l[i + 3]])
		if len(set(l[0:3])) == len(sl) and l[mi + 3] == min(l[3:6]):
			print('FAIR')
		else:
			print('NOT FAIR')
	elif len(set(l[0:3])) == 3 and len(set(l[3:6])) == 3:
		if l[mi + 3] == min(l[3:6]) and l[xi + 3] == max(l[3:6]):
			print('FAIR')
		else:
			print('NOT FAIR')
	else:
		print('NOT FAIR')


for _ in range(int(input())):
	L = list(map(int, input().split()))
	(A, C) = (L[:3], L[3:])
	X = sorted(zip(A, C))
	flag = True
	for i in range(2):
		if X[i][0] < X[i + 1][0] and X[i][1] >= X[i + 1][1]:
			flag = False
		elif X[i][0] == X[i + 1][0] and X[i][1] != X[i + 1][1]:
			flag = False
	print('FAIR' if flag else 'NOT FAIR')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	z = sorted(zip(l[:3], l[3:]))
	flag = True
	for i in range(2):
		if z[i][0] == z[i + 1][0] and z[i][1] != z[i + 1][1] or (z[i][0] < z[i + 1][0] and z[i][1] >= z[i + 1][1]):
			flag = False
			break
	if flag:
		print('FAIR')
	else:
		print('NOT FAIR')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l = sorted(zip(l[:3], l[3:]))
	for i in range(2):
		if l[i][0] < l[i + 1][0] and l[i][1] < l[i + 1][1] or (l[i][0] == l[i + 1][0] and l[i][1] == l[i + 1][1]):
			continue
		else:
			print('NOT FAIR')
			break
	else:
		print('FAIR')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	lt = []
	for i in range(3):
		lt.append((l[i], l[i + 3]))
	lt.sort()
	(a, b) = (0, 0)
	for i in lt:
		(p, q) = i
		if p > a and q > b or (p == a and q == b):
			(a, b) = (p, q)
		else:
			print('NOT FAIR')
			break
	else:
		print('FAIR')


t = input()
for c in range(0, int(t)):
	l = list(map(int, input().split()))
	x = l[:3]
	y = l[3:]
	z = sorted(x)
	u = []
	for i in range(3):
		for j in range(3):
			if z[i] == x[j]:
				u.append(y[j])
	y = sorted(u)
	if u == y and len(set(z)) == len(set(y)):
		print('FAIR')
	else:
		print('NOT FAIR')


for _ in range(int(input())):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	fnf = 'FAIR'
	d = {'1': a1, '2': a2, '3': a3}
	d = sorted([(v, k) for (k, v) in d.items()], reverse=True)
	c = []
	a = []
	for (v, k) in d:
		if k == '1':
			c.append(c1)
			a.append(a1)
		if k == '2':
			c.append(c2)
			a.append(a2)
		if k == '3':
			c.append(c3)
			a.append(a3)
	(a1, a2, a3, c1, c2, c3) = (a[0], a[1], a[2], c[0], c[1], c[2])
	if a1 > a2 and c1 <= c2:
		fnf = 'NOT FAIR'
	elif a1 == a2 and c1 != c2:
		fnf = 'NOT FAIR'
	elif a2 > a3 and c2 <= c3:
		fnf = 'NOT FAIR'
	elif a2 == a3 and c2 != c3:
		fnf = 'NOT FAIR'
	print(fnf)


tests = int(input())
for i in range(tests):
	arr = list(map(int, input().split()))
	ans = 'FAIR'
	money_dist = {}
	for j in range(3):
		if arr[j] in money_dist and money_dist[arr[j]] != arr[j + 3]:
			ans = 'NOT FAIR'
			break
		else:
			money_dist[arr[j]] = arr[j + 3]
	if ans == 'FAIR':
		people_age = sorted(arr[:3])
		people_money = sorted(arr[3:])
		for j in range(3):
			if money_dist[people_age[j]] != people_money[j]:
				ans = 'NOT FAIR'
				break
			if j != 0 and (people_age[j] != people_age[j - 1] and money_dist[people_age[j]] == money_dist[people_age[j - 1]]):
				ans = 'NOT FAIR'
				break
	print(ans)


for _ in range(int(input())):
	(a, b, c, a1, b1, c1) = map(int, input().split())
	lis = [(a, a1), (b, b1), (c, c1)]
	lis.sort()
	s = 0
	for i in range(len(lis) - 1):
		if lis[i][0] == lis[i + 1][0]:
			if lis[i][1] != lis[i + 1][1]:
				s = 0
				break
		elif lis[i][1] >= lis[i + 1][1]:
			s = 0
			break
		s = 1
	if s == 1:
		print('FAIR')
	else:
		print('NOT FAIR')


def check(v1, v2):
	if v1 > 0 and v2 > 0:
		return True
	elif v1 == 0 and v2 == 0:
		return True
	elif v1 < 0 and v2 < 0:
		return True
for _ in range(int(input())):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	t1 = check(a1 - a2, c1 - c2)
	t2 = check(a1 - a3, c1 - c3)
	t3 = check(a2 - a3, c2 - c3)
	if t1 and t2 and t3:
		print('FAIR')
	else:
		print('NOT FAIR')


t = int(input())
for _ in range(t):
	l = [int(i) for i in input().split()]
	a = [[l[i], l[i + 3]] for i in range(3)]
	a.sort()
	flag = False
	if a[0][0] < a[1][0] and a[0][1] >= a[1][1]:
		flag = True
	elif a[0][0] == a[1][0] and a[0][1] != a[1][1]:
		flag = True
	if a[0][0] < a[2][0] and a[0][1] >= a[2][1]:
		flag = True
	elif a[0][0] == a[2][0] and a[0][1] != a[2][1]:
		flag = True
	if a[1][0] < a[2][0] and a[1][1] >= a[2][1]:
		flag = True
	elif a[1][0] == a[2][0] and a[1][1] != a[2][1]:
		flag = True
	if flag:
		print('NOT FAIR')
	else:
		print('FAIR')


t = int(input())
for _ in range(t):
	l = [int(x) for x in input().split()]
	d = {l[i]: l[i + 3] for i in range(3)}
	e = sorted(d)
	if len(d) == 1:
		if l[3] == l[4] == l[5]:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif len(d) == 2:
		if l[0] == l[1]:
			if l[0] > l[2]:
				if l[3] == l[4] and l[3] > l[5]:
					print('FAIR')
				else:
					print('NOT FAIR')
			elif l[3] == l[4] and l[3] < l[5]:
				print('FAIR')
			else:
				print('NOT FAIR')
		elif l[1] == l[2]:
			if l[1] > l[0]:
				if l[4] == l[5] and l[4] > l[3]:
					print('FAIR')
				else:
					print('NOT FAIR')
			elif l[4] == l[5] and l[4] < l[3]:
				print('FAIR')
			else:
				print('NOT FAIR')
		elif l[0] > l[1]:
			if l[3] == l[5] and l[3] > l[4]:
				print('FAIR')
			else:
				print('NOT FAIR')
		elif l[3] == l[5] and l[3] < l[4]:
			print('FAIR')
		else:
			print('NOT FAIR')
	else:
		b = d[e[0]] < d[e[1]] and d[e[1]] < d[e[2]]
		if b:
			print('FAIR')
		else:
			print('NOT FAIR')


def main():
	tsc = int(input())
	for i in range(tsc):
		arr1 = [int(k) for k in input().split()]
		A1 = arr1[0]
		A2 = arr1[1]
		A3 = arr1[2]
		C1 = arr1[3]
		C2 = arr1[4]
		C3 = arr1[5]
		if sign(A1, A2) == sign(C1, C2) and sign(A1, A3) == sign(C1, C3) and (sign(A2, A3) == sign(C2, C3)):
			print('FAIR')
		else:
			print('NOT FAIR')

def sign(x, y):
	if x > y:
		return 1
	elif y > x:
		return -1
	else:
		return 0
main()


for _ in range(int(input())):
	(a, b, c, p, q, r) = map(int, input().split())
	l = [a, b, c]
	z = [p, q, r]
	l.sort()
	z.sort()
	if l.index(a) == z.index(p) and l.index(b) == z.index(q) and (l.index(c) == z.index(r)):
		print('FAIR')
	else:
		print('NOT FAIR')


T = int(input())
for _ in range(T):
	(a, b, c, d, e, f) = map(int, input().split())
	if a < b < c:
		if d < e < f:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a < c < b:
		if d < f < e:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif b < c < a:
		if e < f < d:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif b < a < c:
		if e < d < f:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif c < a < b:
		if f < d < e:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif c < b < a:
		if f < e < d:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a == b == c:
		if d == e == f:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a == b < c:
		if d == e < f:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a == b > c:
		if d == e > f:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a < b == c:
		if d < e == f:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a > b == c:
		if d > e == f:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a == c < b:
		if d == f < e:
			print('FAIR')
		else:
			print('NOT FAIR')
	elif a == c > b:
		if d == f > e:
			print('FAIR')
		else:
			print('NOT FAIR')


for _ in range(int(input())):
	(a, b, c, a1, b1, c1) = map(int, input().split())
	age = [a, b, c]
	money = [a1, b1, c1]
	age.sort()
	money.sort()
	if age.index(a) == money.index(a1) and age.index(b) == money.index(b1) and (age.index(c) == money.index(c1)):
		print('FAIR')
	else:
		print('NOT FAIR')


T = int(input())
for tj in range(T):
	(A1, A2, A3, C1, C2, C3) = map(int, input().split())
	comp_1 = False
	comp_2 = False
	comp_3 = False
	if A1 > A2:
		if C1 > C2:
			comp_1 = True
		else:
			comp_1 = False
	elif A1 == A2:
		if C1 == C2:
			comp_1 = True
		else:
			comp_1 = False
	elif C1 < C2:
		comp_1 = True
	else:
		comp_1 = False
	if A1 > A3:
		if C1 > C3:
			comp_2 = True
		else:
			comp_2 = False
	elif A1 == A3:
		if C1 == C3:
			comp_2 = True
		else:
			comp_2 = False
	elif C1 < C3:
		comp_2 = True
	else:
		comp_2 = False
	if A2 > A3:
		if C2 > C3:
			comp_3 = True
		else:
			comp_3 = False
	elif A3 == A2:
		if C3 == C2:
			comp_3 = True
		else:
			comp_3 = False
	elif C2 < C3:
		comp_3 = True
	else:
		comp_3 = False
	if comp_3 and comp_2 and comp_1:
		print('FAIR')
	else:
		print('NOT FAIR')


for _ in range(int(input())):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	a = [a1, a2, a3]
	c = [c1, c2, c3]
	f = 0
	for i in range(2):
		if a[i] == a[i + 1]:
			if c[i] == c[i + 1]:
				f = 1
			else:
				f = 0
				break
		elif a[i] > a[i + 1]:
			if c[i] > c[i + 1]:
				f = 1
			else:
				f = 0
				break
		elif a[i] < a[i + 1]:
			if c[i] < c[i + 1]:
				f = 1
			else:
				f = 0
				break
		if a[0] > a[2]:
			if c[0] > c[2]:
				f = 1
			else:
				f = 0
		elif a[0] == a[2]:
			if c[0] == c[2]:
				f = 1
			else:
				f = 0
		elif c[0] < c[2]:
			f = 1
		else:
			f = 0
	if f == 0:
		print('NOT FAIR')
	else:
		print('FAIR')


for i in range(int(input())):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	f = 0
	if a1 > a2 and c1 <= c2 or (a1 < a2 and c1 >= c2):
		f = 1
	elif a1 > a3 and c1 <= c3 or (a1 < a3 and c1 >= c3):
		f = 1
	elif a2 > a3 and c2 <= c3 or (a2 < a3 and c2 >= c3):
		f = 1
	elif a1 == a2 and c1 != c2 or (a1 == a3 and c1 != c3) or (a2 == a3 and c2 != c3):
		f = 1
	if f == 0:
		print('FAIR')
	else:
		print('NOT FAIR')


for t in range(int(input())):
	(A1, A2, A3, C1, C2, C3) = [int(x) for x in input().split()]
	A = [A1, A2, A3]
	C = [C1, C2, C3]
	ok = True
	for i in range(2):
		for j in range(i, 3):
			if A[i] > A[j] and C[i] <= C[j]:
				ok = False
				break
			elif A[i] < A[j] and C[j] <= C[i]:
				ok = False
				break
			elif A[i] == A[j] and C[i] != C[j]:
				ok = False
				break
	if ok:
		print('FAIR')
	else:
		print('NOT FAIR')


T = int(input())
for _ in range(T):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	flag = 0
	if a1 > a2 and c1 <= c2 or (a1 > a3 and c1 <= c3):
		flag = 1
	elif a2 > a3 and c2 <= c3 or (a2 > a1 and c2 <= c1):
		flag = 1
	elif a3 > a1 and c3 <= c1 or (a3 > a2 and c3 <= c2):
		flag = 1
	elif a3 == a1 and c3 != c1 or (a2 == a1 and c2 != c1) or (a2 == a3 and c2 != c3):
		flag = 1
	if flag == 1:
		print('NOT FAIR')
	else:
		print('FAIR')


def solve(s1, s2, s3, c1, c2, c3):
	s = [s1, s2, s3]
	c = [c1, c2, c3]
	for i in range(3):
		for j in range(i + 1, 3):
			if s[i] > s[j] and c[i] <= c[j]:
				return False
			if s[j] > s[i] and c[i] >= c[j]:
				return False
			if s[i] == s[j] and c[i] != c[j]:
				return False
	return True

def main():
	for item in range(int(input())):
		(s1, s2, s3, c1, c2, c3) = map(int, input().split())
		if solve(s1, s2, s3, c1, c2, c3):
			print('FAIR')
		else:
			print('NOT FAIR')
main()


t = int(input())
for _ in range(t):
	A = [0, 0, 0]
	C = [0, 0, 0]
	(A[0], A[1], A[2], C[0], C[1], C[2]) = map(int, input().split())
	flag = True
	for i in range(3):
		for j in range(i + 1, 3):
			if A[i] > A[j]:
				if C[i] <= C[j]:
					flag = False
			if A[i] < A[j]:
				if C[i] >= C[j]:
					flag = False
			if A[i] == A[j]:
				if C[i] != C[j]:
					flag = False
	if flag:
		print('FAIR')
	else:
		print('NOT FAIR')


t = int(input())
for _ in range(t):
	(a, b, c, m, n, p) = map(int, input().split())
	f = 0
	if a > b and m <= n or (a < b and m >= n):
		f = 1
	if a > c and m <= p or (a < c and m >= p):
		f = 1
	if b > c and n <= p or (b < c and n >= p):
		f = 1
	if a == b and m != n or (b == c and n != p) or (a == c and m != p):
		f = 1
	if f == 0:
		print('FAIR')
	else:
		print('NOT FAIR')


total_testcases = int(input())
for testcase in range(total_testcases):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	d = []
	d.append({'age': a1, 'amount': c1})
	d.append({'age': a2, 'amount': c2})
	d.append({'age': a3, 'amount': c3})
	d = sorted(d, key=lambda entry: entry['age'])
	result = True
	for i in range(3):
		for j in range(i + 1, 3):
			if d[i]['age'] == d[j]['age']:
				if d[i]['amount'] != d[j]['amount']:
					result = False
					break
			elif d[i]['amount'] >= d[j]['amount']:
				result = False
				break
	print('FAIR' if result else 'NOT FAIR')


for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	counter = True
	for i in range(3):
		for j in range(i, 3):
			if a[i] < a[j]:
				if a[i + 3] >= a[j + 3]:
					counter = False
					break
			elif a[i] > a[j]:
				if a[i + 3] <= a[j + 3]:
					counter = False
					break
			elif a[i] == a[j]:
				if a[i + 3] != a[j + 3]:
					counter = False
					break
	if counter:
		print('FAIR')
	else:
		print('NOT FAIR')


t = int(input())
for _ in range(t):
	(a1, a2, a3, m, n, p) = map(int, input().split())
	f = 0
	if a1 > a2 and m <= n or (a1 < a2 and m >= n):
		f = 1
	if a1 > a3 and m <= p or (a1 < a3 and m >= p):
		f = 1
	if a2 > a3 and n <= p or (a2 < a3 and n >= p):
		f = 1
	if a1 == a2 and m != n or (a2 == a3 and n != p) or (a1 == a3 and m != p):
		f = 1
	if f == 0:
		print('FAIR')
	else:
		print('NOT FAIR')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = a[:3]
	c = a[3:]
	d = 0
	for i in range(3):
		if b[i] == max(b):
			if c[i] != max(c):
				d = 1
				break
		elif c[i] == max(c):
			if b[i] != max(b):
				d = 1
				break
		elif b[i] == min(b):
			if c[i] != min(c):
				d = 1
				break
		elif c[i] == min(c):
			if b[i] != min(b):
				d = 1
				break
	if d == 1:
		print('NOT FAIR')
	else:
		print('FAIR')


n = int(input())
for i in range(n):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	if a1 == a2 and c1 != c2 or (a2 == a3 and c2 != c3) or (a1 == a3 and c1 != c3) or (a1 == a2 == a3 and c1 != c2 != c3):
		print('NOT FAIR')
	elif a1 > a2 and c1 <= c2 or (a1 > a3 and c1 <= c3) or (a2 > a3 and c2 <= c3):
		print('NOT FAIR')
	elif a1 < a2 and c1 >= c2 or (a1 < a3 and c1 >= c3) or (a2 < a3 and c2 >= c3):
		print('NOT FAIR')
	else:
		print('FAIR')


for i in range(int(input())):
	ans = 'FAIR'
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	if a1 == a2 and c1 != c2:
		ans = 'NOT FAIR'
	elif a2 == a3 and c2 != c3:
		ans = 'NOT FAIR'
	elif a3 == a1 and c3 != c1:
		ans = 'NOT FAIR'
	elif a1 < a2 and c1 >= c2:
		ans = 'NOT FAIR'
	elif a2 < a3 and c2 >= c3:
		ans = 'NOT FAIR'
	elif a3 < a1 and c3 >= c1:
		ans = 'NOT FAIR'
	elif a1 > a2 and c1 <= c2:
		ans = 'NOT FAIR'
	elif a2 > a3 and c2 <= c3:
		ans = 'NOT FAIR'
	elif a3 > a1 and c3 <= c1:
		ans = 'NOT FAIR'
	print(ans)


def fairity(k):
	if k[0] == k[1] and k[3] != k[4] or (k[0] == k[2] and k[3] != k[5]) or (k[1] == k[2] and k[4] != k[5]):
		return 0
	elif k[0] > k[1] and k[3] <= k[4] or (k[0] > k[2] and k[3] <= k[5]) or (k[1] > k[2] and k[4] <= k[5]):
		return 0
	elif k[0] < k[1] and k[3] >= k[4] or (k[0] < k[2] and k[3] >= k[5]) or (k[1] < k[2] and k[4] >= k[5]):
		return 0
	return 1
t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	print('FAIR' if fairity(l) == 1 else 'NOT FAIR')


def check(l):
	if l[0] == l[1] and l[3] != l[4] or (l[0] == l[2] and l[3] != l[5]) or (l[1] == l[2] and l[4] != l[5]):
		return 0
	elif l[0] > l[1] and l[3] <= l[4] or (l[0] > l[2] and l[3] <= l[5]) or (l[1] > l[2] and l[4] <= l[5]):
		return 0
	elif l[0] < l[1] and l[3] >= l[4] or (l[0] < l[2] and l[3] >= l[5]) or (l[1] < l[2] and l[4] >= l[5]):
		return 0
	return 1
n = int(input())
while n:
	l = list(map(int, input().split()))
	if check(l) == 1:
		print('FAIR')
	else:
		print('NOT FAIR')
	n = n - 1


try:
	for i in range(int(input())):
		nums = [int(item) for item in input().split()]
		ages = nums[0:len(nums) // 2]
		gifts = nums[len(nums) // 2:len(nums)]
		my_list = list(zip(ages, gifts))
		my_list.sort(key=lambda x: x[0])
		valid = True
		for i in range(len(my_list) - 1):
			for j in range(len(my_list)):
				if my_list[i][0] < my_list[j][0]:
					if my_list[i][1] < my_list[j][1]:
						continue
					else:
						valid = False
						break
				elif my_list[i][0] == my_list[j][0]:
					if my_list[i][1] == my_list[j][1]:
						continue
					else:
						valid = False
						break
			if not valid:
				print('NOT FAIR')
				break
		if valid:
			print('FAIR')
except EOFError:
	pass


try:
	n = int(input().strip())
	for k in range(n):
		(a1, a2, a3, c1, c2, c3) = map(int, input().strip().split(' '))
		l = [[a1, c1], [a2, c2], [a3, c3]]
		l.sort(reverse=True)
		f = 0
		for i in range(2):
			if l[i][1] < l[i + 1][1]:
				f = 1
				break
			elif l[i][1] == l[i + 1][1]:
				if l[i][0] != l[i + 1][0]:
					f = 1
					break
			elif l[i][1] > l[i + 1][1] and l[i][0] == l[i + 1][0]:
				f = 1
				break
		if f == 1:
			print('NOT FAIR')
		else:
			print('FAIR')
except:
	pass


t = int(input())
for i in range(t):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	a = [a1, a2, a3]
	c = [c1, c2, c3]
	b = a.copy()
	b.sort()
	k = 0
	d = []
	for j in range(3):
		m = b[j]
		d.insert(j, c[a.index(m)])
		c[a.index(m)] = 0
		a[a.index(m)] = 0
	for j in range(2):
		if b[j] < b[j + 1] and d[j] < d[j + 1]:
			k = 1
		elif b[j] == b[j + 1] and d[j] == d[j + 1]:
			k = 1
		else:
			k = 0
			break
	if k == 0:
		print('NOT FAIR')
	else:
		print('FAIR')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	c = a[3:6]
	b = a[0:3]
	c.sort()
	b.sort()
	p = 0
	if b.index(a[0]) == c.index(a[3]) and b.index(a[1]) == c.index(a[4]) and (b.index(a[2]) == c.index(a[5])):
		p = 0
	else:
		p = 1
	if p == 1:
		print('NOT FAIR')
	elif p == 0:
		print('FAIR')


T = int(input())
for i in range(T):
	a = list(map(int, input().split()))
	k = []
	k.extend(a[0:3])
	l = []
	l.extend(a[3:])
	n = []
	m = []
	f = 0
	for j in range(3):
		x = l.index(max(l))
		m.append(max(l))
		n.append(k[x])
		l[x] = 0
	for j in range(2):
		if m[j] > m[j + 1]:
			if n[j] <= n[j + 1]:
				f = 1
		elif m[j] == m[j + 1]:
			if n[j] != n[j + 1]:
				f = 1
		elif m[j] < m[j + 1]:
			if n[j] >= n[j + 1]:
				f = 1
	if f == 1:
		print('NOT FAIR')
	else:
		print('FAIR')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	c = a[3:6]
	a = a[0:3]
	p = 0
	for i in range(len(a)):
		for j in range(i + 1, len(a)):
			if a[i] > a[j] and c[i] > c[j] or (a[i] == a[j] and c[i] == c[j]) or (a[i] < a[j] and c[i] < c[j]):
				p = 0
			else:
				p = 1
				break
		if p == 1:
			break
	if p == 1:
		print('NOT FAIR')
	elif p == 0:
		print('FAIR')


for t in range(int(input())):
	(a1, a2, a3, c1, c2, c3) = map(int, input().split())
	l1 = [a1, a2, a3]
	l2 = [c1, c2, c3]
	l1.sort()
	l2.sort()
	if l1.index(a1) == l2.index(c1) and l1.index(a2) == l2.index(c2) and (l1.index(a3) == l2.index(c3)):
		print('FAIR')
	else:
		print('NOT FAIR')


t = int(input())
while t > 0:
	(a1, a2, a3, c1, c2, c3) = list(map(int, input().split()))
	l = [a1, a2, a3]
	l.sort()
	l1 = [c1, c2, c3]
	l1.sort()
	if l.index(a1) == l1.index(c1) and l.index(a2) == l1.index(c2) and (l.index(a3) == l1.index(c3)):
		print('FAIR')
	else:
		print('NOT FAIR')
	t -= 1


for i in range(int(input())):
	(a, b, c, x, y, z) = map(int, input().split())
	l1 = [a, b, c]
	l2 = [x, y, z]
	l1.sort()
	l2.sort()
	if l1.index(a) == l2.index(x) and l1.index(b) == l2.index(y) and (l1.index(c) == l2.index(z)):
		print('FAIR')
	else:
		print('NOT FAIR')


def isfair(a, b, c, d):
	if a > c and b > d or (a < c and b < d) or (a == c and b == d):
		return True
	else:
		return False
for _ in range(int(input())):
	k = list(map(int, input().strip().split()))
	if isfair(k[0], k[3], k[1], k[4]) and isfair(k[1], k[4], k[2], k[5]) and isfair(k[2], k[5], k[0], k[3]):
		print('FAIR')
	elif isfair(k[0], k[3], k[2], k[5]) and isfair(k[2], k[5], k[1], k[4]) and isfair(k[1], k[4], k[0], k[3]):
		print('FAIR')
	elif isfair(k[1], k[4], k[2], k[5]) and isfair(k[2], k[5], k[0], k[3]) and isfair(k[0], k[3], k[1], k[4]):
		print('FAIR')
	elif isfair(k[1], k[4], k[0], k[3]) and isfair(k[0], k[3], k[2], k[5]) and isfair(k[2], k[5], k[1], k[4]):
		print('FAIR')
	elif isfair(k[2], k[5], k[0], k[3]) and isfair(k[0], k[3], k[1], k[4]) and isfair(k[1], k[4], k[2], k[5]):
		print('FAIR')
	elif isfair(k[2], k[5], k[1], k[4]) and isfair(k[1], k[4], k[0], k[3]) and isfair(k[0], k[3], k[2], k[5]):
		print('FAIR')
	else:
		print('NOT FAIR')


t = int(input())
for h in range(t):
	d = {}
	c = 0
	a = [int(i) for i in input().split()]
	for i in range(3):
		if a[i] in d:
			if d[a[i]] != a[3 + i]:
				c = 1
				break
		d[a[i]] = a[3 + i]
	b = list(d.keys())
	b.sort()
	for i in range(len(b) - 1):
		if b[i] == b[i + 1]:
			if d[b[i]] != d[b[i + 1]]:
				c = 1
				break
		elif d[b[i]] >= d[b[i + 1]]:
			c = 1
			break
	if c == 1:
		print('NOT FAIR')
	else:
		print('FAIR')


t = int(input())
while t > 0:
	(a, b, c, x, y, z) = input().split()
	(a, b, c, x, y, z) = (int(a), int(b), int(c), int(x), int(y), int(z))
	l1 = [a, b, c]
	l2 = [x, y, z]
	l1.sort()
	l2.sort()
	if l1.index(a) == l2.index(x) and l1.index(b) == l2.index(y) and (l1.index(c) == l2.index(z)):
		print('FAIR')
	else:
		print('NOT FAIR')
	t -= 1