def get_ans(x, x1, x2, x3, y1, y2, y3): p1 = x1 + y1 * x p2 = x2 + y2 * x p3 = x3 + y3 * x if (p1 < p2 and p3 < p2 and p1 != p3) or (p1 > p2 and p3 > p2 and p1 != p3): return True return False N = int(input()) for _ in range(N): x1, x2, x3, y1, y2, y3 = map(int, input().split()) ps = [(x1 - x2) / (y2 - y1) if y1 != y2 else -1, (x2 - x3) / (y3 - y2) if y2 != y3 else -1, (x1 - x3) / (y3 - y1) if y1 != y3 else -1] if 0 not in ps: ps.append(0) ps.sort() ps.append(ps[-1] + 1.0) ans = False for i in range(len(ps) - 1): if ps[i] < 0: continue if get_ans(ps[i] + ((ps[i + 1] - ps[i]) / 3), x1, x2, x3, y1, y2, y3) or get_ans(ps[i] + ((ps[i + 1] - ps[i]) * 2 / 3), x1, x2, x3, y1, y2, y3): ans = True break print('YES' if ans else 'NO')