q = int(raw_input()) for iq in xrange(q): n = int(raw_input()) pts = [] xs = [] ys = [] for i in xrange(n): pt = map(int, raw_input().split()) pts.append(pt) xs.append(pt[0]) ys.append(pt[1]) x1 = min(xs) x2 = max(xs) y1 = min(ys) y2 = max(ys) on_edges = True for pt in pts: if not ((pt[0] == x1 and pt[1] >= y1 and pt[1] <= y2) or (pt[0] == x2 and pt[1] >= y1 and pt[1] <= y2) or (pt[1] == y1 and pt[0] >= x1 and pt[0] <= x2) or (pt[1] == y2 and pt[0] >= x1 and pt[0] <= x2)): on_edges = False break print "YES" if on_edges else "NO"