from collections import Counter for _ in range(int(input())): n = int(input()) rectx = Counter() all_points = [] for i in range(n): x, y = map(int, input().split()) rectx.update([x]) all_points.append((x, y)) xs = rectx.most_common()[0] indice = 0 for i in range(xs[1]): if all_points[indice][0] == xs[0]: del all_points[indice] else: indice += 1 if not all_points: print("YES") else: y = all_points[0][1] for element in all_points: if element[1] != y: print("NO") break else: print("YES")