for _ in xrange(int(input())): n = int(input()) xs = [] ys = [] for i in xrange(n): x, y = map(int, raw_input().split()) xs.append(x) ys.append(y) lx, rx, ly, ry = min(xs), max(xs), min(ys), max(ys) good = True for i in xrange(n): if lx < xs[i] < rx and ys[i] != ly and ys[i] != ry: good = False if ly < ys[i] < ry and xs[i] != lx and xs[i] != rx: good = False print "YES" if good else "NO"