def func(x): if x[0] == x[1] or x[0] == x[2]: return False if x[1] > x[0] and x[1] > x[2] : return True if x[1] < x[0] and x[1] < x[2] : return True return False def make(x, y, t) : z = [x[i] for i in range(3)] if t < 0.0 : return x for i in range(3) : z[i] += y[i] * t return z N = int(input()) for case in range(N) : z = list(map(int, input().split())) x = [0 for i in range(3)] y = [0 for i in range(3)] for i in range(3) : x[i] = z[i] for i in range(3) : y[i] = z[i+3] f = func(x) # print('{} {}'.format(x,y)) for i in range(3) : for j in range(i) : if y [i] != y[j] : t = (x[j] - x[i]) / (y[i] - y[j]) if func(make(x, y, t + 0.0000001)) or func(make(x, y, t - 0.0000001)) : f = True # print('{} {} {} {}'.format(i, j, t, make(x, y, t))) print("YES" if f else "NO")