q = int(input()) for _ in range(q): n = int(input()) done = False res = True allowed_x = [] allowed_y = [] for _ in range(n): x, y = map(int, input().split(' ')) if not done: if len(allowed_x) == 0 and len(allowed_y) == 0: allowed_x.append(x) allowed_y.append(y) elif x in allowed_x and y > max(allowed_y): allowed_y.remove(max(allowed_y)) allowed_y.append(y) elif x in allowed_x and y < min(allowed_y): allowed_y.remove(min(allowed_y)) allowed_y.append(y) elif y in allowed_y and x > max(allowed_x): allowed_x.remove(max(allowed_x)) allowed_x.append(x) elif y in allowed_y and x < min(allowed_x): allowed_x.remove(min(allowed_x)) allowed_x.append(x) elif len(allowed_x) == 1 and len(allowed_y) == 1: if x not in allowed_x: allowed_x.append(x) if y not in allowed_y: allowed_y.append(y) elif len(allowed_x) == 2 and len(allowed_y) == 1: if x not in allowed_x: done = True res = False elif y not in allowed_y: allowed_y.append(y) elif len(allowed_x) == 1 and len(allowed_y) == 2: if y not in allowed_y: done = True res = False elif x not in allowed_x: allowed_x.append(x) else: if x in allowed_x and y not in range(min(allowed_y), max(allowed_y)+1) or\ y in allowed_y and x not in range(min(allowed_x), max(allowed_x) + 1) or\ x not in allowed_x and y not in allowed_y: done = True res = False if res: print('YES') else: print('NO')