# Enter your code here. Read input from STDIN. Print output to STDOUT import math from collections import Counter q = input() _ = 0 while _ < q: _ += 1 n = input() t = 0 # a,b = map(int, raw_input().split()) arrx,arry = [],[] nope = False while t < n: x,y = map(int, raw_input().split()) arrx.append(x) arry.append(y) t += 1 countx = Counter(arrx) # print countx a = countx.most_common(2) valx, alx = a[0] valx2, alx2 = a[1] county = Counter(arry) # print arrx # print a a = county.most_common(2) valy, aly = a[0] valy2, aly2 = a[1] # print arry # print a # for each in range(len(arrx)): each = 0 while each < n: if arrx[each] != valx and arrx[each] != valx2 and arry[each] != valy2 and arry[each] != valy: nope = True break each += 1 if nope: print "NO" else: print "YES"