# Enter your code here. Read input from STDIN. Print output to STDOUT q=int(raw_input()) for i in range(q): n=int(raw_input()) YES=True x_list=[] y_list=[] for j in range(n): x,y=map(int,raw_input().split()) if len(x_list) < 2 and (x not in x_list): x_list.append(x) if len(y_list) < 2 and (y not in y_list): y_list.append(y) if len(x_list)==2 and len(y_list)==2 and (x not in x_list) and (y not in y_list): YES=False #print(x_list) #print(y_list) if YES: print("YES") else: print("NO")