for _q in range(int(input().strip())): points = [tuple(map(int,input().strip().split())) for _ in range(int(input().strip()))] x0 = min([point[0] for point in points]) x1 = max([point[0] for point in points]) y0 = min([point[1] for point in points]) y1 = max([point[1] for point in points]) # print(x0,x1,y0,y1) # for point in points: # print(point[0] == x0) # print(point[0] == x0 or point[0] == x1 | point[1] == y0 | point[1] == y1) # print([(point[0] == x0 | point[0] == x1 | point[1] == y0 | point[1] == y1) for point in points]) if (all([(point[0] == x0 or point[0] == x1 or point[1] == y0 or point[1] == y1) for point in points])): print("YES") else: print("NO")