#include<iostream>
using namespace std;
struct vect{
  double x,y;
};
double Sc(vect a,vect b,vect c){
  double S;
  b.x = b.x - a.x;
  b.y = b.y - a.y;
  c.x = c.x - a.x;
  c.y = c.y - a.y;
  S = b.x * c.y - b.y * c.x;
  if(S >= 0){
    return S/2;} else if(S < 0){
    return -S/2;
  }
}

int main(){
  vect a,b,c,p;
  int n;
  cin >> n;
  
  while(cin >> a.x >> a.y  >> b.x >> b.y >>c.x >>c.y >> p.x >> p.y){
   if(Sc(a,b,p) == 0 || Sc(a,p,c)== 0|| Sc(p,b,c)==0 ){
     cout << "NO"<< endl;    } else  if(Sc(a,b,p) +Sc(a,p,c) +Sc(p,b,c) == Sc (a,b,c)){    cout << "YES" << endl;
    }else {cout << "NO" << endl;}
    
  }
}