#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrtl(powl(b.x - a.x, 2) + powl(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    long double ratio = b_to_i / mag;
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

//    long double angle_a = powl(b.x - c.x, 2) + powl(b.y - c.y, 2);
    long long angle_a = (long)(b.x - c.x)*(b.x - c.x) + (long)(b.y - c.y)*(b.y - c.y);
//    long double angle_b = powl(c.x - a.x, 2) + powl(c.y - a.y, 2);
    long long angle_b = (long)(c.x - a.x)*(c.x - a.x) + (long)(c.y - a.y)*(c.y - a.y);
//    long double angle_c = powl(a.x - b.x, 2) + powl(a.y - b.y, 2);
    long long angle_c = (long)(a.x - b.x)*(a.x - b.x) + (long)(a.y - b.y)*(a.y - b.y);

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        if (i == 2243)
        {
            cout << l1.a.x << " " << l1.a.y << " " << l1.b.x << " " << l1.b.y
                 << " " << l2.a.x << " " << l2.a.y << " " << l2.b.x << " " << l2.b.y
                 << " " << l3.a.x << " " << l3.a.y << " " << l3.b.x << " " << l3.b.y << endl;
        }

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrt(pow(b.x - a.x, 2) + pow(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    auto ratio = (float)(b_to_i / mag);
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

//    long double angle_a = powl(b.x - c.x, 2) + powl(b.y - c.y, 2);
    long long angle_a = (long)(b.x - c.x)*(b.x - c.x) + (long)(b.y - c.y)*(b.y - c.y);
//    long double angle_b = powl(c.x - a.x, 2) + powl(c.y - a.y, 2);
    long long angle_b = (long)(c.x - a.x)*(c.x - a.x) + (long)(c.y - a.y)*(c.y - a.y);
//    long double angle_c = powl(a.x - b.x, 2) + powl(a.y - b.y, 2);
    long long angle_c = (long)(a.x - b.x)*(a.x - b.x) + (long)(a.y - b.y)*(a.y - b.y);

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        if (i == 2243)
        {
            string blah = "0 0 100000000 100000000 -100000000 100000000 0 0 -20000000 20000000 50000000 50000000";
        }

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrtl(powl(b.x - a.x, 2) + powl(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    long double ratio = b_to_i / mag;
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

    long double angle_a = powl(b.x - c.x, 2) + powl(b.y - c.y, 2);
    long double angle_b = powl(c.x - a.x, 2) + powl(c.y - a.y, 2);
    long double angle_c = powl(a.x - b.x, 2) + powl(a.y - b.y, 2);

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrtl(powl(b.x - a.x, 2) + powl(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    long double ratio = b_to_i / mag;
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

//    long double angle_a = powl(b.x - c.x, 2) + powl(b.y - c.y, 2);
    long angle_a = (long)(b.x - c.x)*(b.x - c.x) + (long)(b.y - c.y)*(b.y - c.y);
//    long double angle_b = powl(c.x - a.x, 2) + powl(c.y - a.y, 2);
    long angle_b = (long)(c.x - a.x)*(c.x - a.x) + (long)(c.y - a.y)*(c.y - a.y);
//    long double angle_c = powl(a.x - b.x, 2) + powl(a.y - b.y, 2);
    long angle_c = (long)(a.x - b.x)*(a.x - b.x) + (long)(a.y - b.y)*(a.y - b.y);

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrt(pow(b.x - a.x, 2) + pow(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    auto ratio = b_to_i / mag;
    return ratio >= 0.1999999999999 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

//    long double angle_a = powl(b.x - c.x, 2) + powl(b.y - c.y, 2);
    long long angle_a = (long)(b.x - c.x)*(b.x - c.x) + (long)(b.y - c.y)*(b.y - c.y);
//    long double angle_b = powl(c.x - a.x, 2) + powl(c.y - a.y, 2);
    long long angle_b = (long)(c.x - a.x)*(c.x - a.x) + (long)(c.y - a.y)*(c.y - a.y);
//    long double angle_c = powl(a.x - b.x, 2) + powl(a.y - b.y, 2);
    long long angle_c = (long)(a.x - b.x)*(a.x - b.x) + (long)(a.y - b.y)*(a.y - b.y);

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

//        if (i == 2243)
//        {
//            string blah = "0 0 100000000 100000000 -100000000 100000000 0 0 -20000000 20000000 50000000 50000000";
//        }

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrtl(powl(b.x - a.x, 2) + powl(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    long double ratio = b_to_i / mag;
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

    long angle_a = (long)(powl(b.x - c.x, 2) + powl(b.y - c.y, 2));
    long angle_b = (long)(powl(c.x - a.x, 2) + powl(c.y - a.y, 2));
    long angle_c = (long)(powl(a.x - b.x, 2) + powl(a.y - b.y, 2));

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrtl(powl(b.x - a.x, 2) + powl(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    long double ratio = b_to_i / mag;
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

//    long double angle_a = powl(b.x - c.x, 2) + powl(b.y - c.y, 2);
    long long angle_a = (long)(b.x - c.x)*(b.x - c.x) + (long)(b.y - c.y)*(b.y - c.y);
//    long double angle_b = powl(c.x - a.x, 2) + powl(c.y - a.y, 2);
    long long angle_b = (long)(c.x - a.x)*(c.x - a.x) + (long)(c.y - a.y)*(c.y - a.y);
//    long double angle_c = powl(a.x - b.x, 2) + powl(a.y - b.y, 2);
    long long angle_c = (long)(a.x - b.x)*(a.x - b.x) + (long)(a.y - b.y)*(a.y - b.y);

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        if (i == 2243)
        {
            cout << l1.a.x << l1.a.y << l1.b.x << l1.b.y
                 << l2.a.x << l2.a.y << l2.b.x << l2.b.y
                 << l3.a.x << l3.a.y << l3.b.x << l3.b.y << endl;
        }

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrtl(powl(b.x - a.x, 2) + powl(b.y - a.y, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    long double ratio = b_to_i / mag;
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

//    long double angle_a = powl(b.x - c.x, 2) + powl(b.y - c.y, 2);
    long long angle_a = (long)(b.x - c.x)*(b.x - c.x) + (long)(b.y - c.y)*(b.y - c.y);
//    long double angle_b = powl(c.x - a.x, 2) + powl(c.y - a.y, 2);
    long long angle_b = (long)(c.x - a.x)*(c.x - a.x) + (long)(c.y - a.y)*(c.y - a.y);
//    long double angle_c = powl(a.x - b.x, 2) + powl(a.y - b.y, 2);
    long long angle_c = (long)(a.x - b.x)*(a.x - b.x) + (long)(a.y - b.y)*(a.y - b.y);

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2)) ? "YES" : "NO") << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    long long x;
    long long y;
    bool operator == (const Point& otherP)
    {
        return (x == otherP.x && y == otherP.y);
    }
};

struct Line
{
    Point a;
    Point b;
};

bool collinear(Point& a, Point& b, Point& c)
{
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) == 0;
}

long double dist(Point& a, Point& b)
{
    return sqrtl(powl(b.x - a.x, 2) + powl(b.y - a.x, 2));
}

bool measurements(Point& a, Point& inter, Point& b)
{
    long double mag = dist(a, b);         // Outer line magnitude
    long double a_to_i = dist(a, inter);  // From point a to intersection
    long double b_to_i = dist(b, inter);  // From point b to intersection

    if (a_to_i > mag || b_to_i > mag) return false;  // Doesn't intersect

    long double ratio = b_to_i / mag;
    return ratio >= 0.2 && ratio <= 0.8;  // Problem description
}

// See if the angle created by the three points is > 0 and <= 90
bool angle(Point& a, Point& b, Point& c)
{
    if ((a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y) == 0) return false;

    long angle_a = (long)(powl(b.x - c.x, 2) + powl(b.y - c.y, 2));
    long angle_b = (long)(powl(c.x - a.x, 2) + powl(c.y - a.y, 2));
    long angle_c = (long)(powl(a.x - b.x, 2) + powl(a.y - b.y, 2));

    return angle_c <= angle_a + angle_b;
}

// See if two lines create the 'outer' part of the 'A'
// This is true if the lines share an endpoint and the angle created is > 0 and <= 90
bool outer(Line& l1, Line& l2)
{
    if (l1.a == l2.a)
        return angle(l1.b, l2.b, l1.a);
    if (l1.a == l2.b)
        return angle(l1.b, l2.a, l1.a);
    if (l1.b == l2.a)
        return angle(l1.a, l2.b, l1.b);
    if (l1.b == l2.b)
        return angle(l1.a, l2.a, l1.b);
    return false;  // No common endpoints
}

bool inner(Line& outer, Line& inner)
{
    // Make sure one of the inner endpoints is on the line
    if (collinear(outer.a, inner.a, outer.b))
    {
        return measurements(outer.a, inner.a, outer.b);
    }
    else if (collinear(outer.a, inner.b, outer.b))
    {
        return measurements(outer.a, inner.b, outer.b);
    }
    else
    {
        return false; // The inner line doesn't end on the outer line
    }
}

bool A(Line& o1, Line& o2, Line& inter)
{
    return outer(o1, o2) && inner(o1, inter) && inner(o2, inter);
}

int main()
{
    int rows;
    long long x1, x2, y1, y2;
    cin >> rows;

    for (int i = 0; i <= rows; ++i)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l1{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l2{x1, y1, x2, y2};
        cin >> x1 >> y1 >> x2 >> y2;
        Line l3{x1, y1, x2, y2};

        cout << ((A(l1, l2, l3) || A(l2, l3, l1) || A(l3, l1, l2))? "YES" : "NO") << endl;
    }
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}

	friend inline pair<ll, ll> calVector(const coor &A, const coor &B) {
		return{ B.x - A.x, B.y - A.y };
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	p2ll AB = calVector(p[sp.first].first, p[sp.first].second);
	p2ll CD = calVector(p[sp.second].first, p[sp.second].second);
	double head = (AB.first*CD.first + AB.second*CD.second);
	double bot = sqrt(AB.first*AB.first*1.0 + AB.second*AB.second*1.0) * sqrt(CD.first*CD.first*1.0 + CD.second*CD.second*1.0);
	double deg = acos(fabs(head / bot))*(180.0 / pi);

	return 0 < deg && deg <= 90;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return ((d == (d1 + d2)) && (0.25 <= (d1 / d2)) && ((d1 / d2) <= 4));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}

				if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}

	friend inline pair<ll, ll> calVector(const coor &A, const coor &B) {
		return{ B.x - A.x, B.y - A.y };
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	p2ll AB = calVector(p[sp.first].first, p[sp.first].second);
	p2ll CD = calVector(p[sp.second].first, p[sp.second].second);
	double head = (AB.first*CD.first + AB.second*CD.second);
	double bot = sqrt(AB.first*AB.first*1.0 + AB.second*AB.second*1.0) * sqrt(CD.first*CD.first*1.0 + CD.second*CD.second*1.0);
	double deg = acos(fabs(head / bot))*(180.0 / pi);

	return deg > 0 && deg <= 90;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (!calDistance(p[it].first, p[it].second)) {
					cout << "NO" << endl;
					continue;
				}

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}

				if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
//============================================================================================

struct segment {
	ld a = 0, b = 0, c = 0;
} firstSegment, secondSegment;

struct pairCoor {
	p2ld a, b;
};

int cou;
pairCoor p[3];
pii po;
int tc;

inline double calDistance(const p2ld &a, const p2ld &b) {
	return sqrt(p(b.first - a.first) + p(b.second - a.second));
}

// giải phương trình đường thẳng
inline pdd solveTQE2H(const pairCoor &pc, segment &mySegmet) {
	double a = pc.b.second - pc.a.second;
	double b = pc.b.first - pc.a.first;

	if (!a && !b) {
		mySegmet.a = 0, mySegmet.b = 0, mySegmet.c = 0;
		return make_pair(0, 0);
	}

	if (!a) {
		mySegmet.a = 0, mySegmet.b = 1, mySegmet.c = -pc.a.second;
		return make_pair(0, 1);
	}

	if (!b) {
		mySegmet.a = 1, mySegmet.b = 0, mySegmet.c = -pc.a.first;
		return make_pair(1, 0);
	}

	mySegmet.a = a, mySegmet.b = -b, mySegmet.c = ((-pc.a.first*a) - (-pc.a.second*b));
	return make_pair(a, -b);
}

// tìm 2 cạnh có cùng 1 điểm chung
inline pii findSamePoint() {
	pii res = { -1, -1 };

	forn(i, 3, 0) {
		forn(j, 3, i + 1) {
			if (p[i].a == p[j].a || p[i].a == p[j].b) {
				res = { i, j };
				++cou;
			}

			if (p[i].b == p[j].a || p[i].b == p[j].b) {
				res = { i, j };
				++cou;
			}
		}
	}

	return cou == 1 ? res : make_pair(-1, -1);
}

inline bool isAc() {
	int thirdSegment = 3 - po.first - po.second;

	if ((firstSegment.a*p[thirdSegment].a.first + firstSegment.b*p[thirdSegment].a.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].b.first + secondSegment.b*p[thirdSegment].b.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].a);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].a);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].b);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].b);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 + f2 <= f + 0.0000001 && s1 + s2 <= s + 0.0000001) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	if ((firstSegment.a*p[thirdSegment].b.first + firstSegment.b*p[thirdSegment].b.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].a.first + secondSegment.b*p[thirdSegment].a.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].b);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].b);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].a);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].a);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 + f2 <= f + 0.0000001 && s1 + s2 <= s + 0.0000001) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	return false;
}

// tính số đo góc kẹp giữa
inline double calAngleBetween() {
	p2ld A = solveTQE2H(p[po.first], firstSegment);
	p2ld B = solveTQE2H(p[po.second], secondSegment);

	ld dot = fabs(A.first*B.first + A.second*B.second);
	ld d1 = sqrt(p(A.first) + p(A.second));
	ld d2 = sqrt(p(B.first) + p(B.second));

	return acos(dot / (d1*d2))*(180.0 / pi);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	cin >> tc;

	while (tc--) {
		cou = 0;

		forn(i, 3, 0) {
			cin >> p[i].a.first >> p[i].a.second >> p[i].b.first >> p[i].b.second;
		}

		po = findSamePoint();

		if (3 - po.first - po.second <= 2) {
			double angleBetween = calAngleBetween();

			if (angleBetween <= 90 && angleBetween > 0) {
				if (isAc()) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	return AB + AC > BC;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
//============================================================================================

struct segment {
	ld a = 0, b = 0, c = 0;
} firstSegment, secondSegment;

struct pairCoor {
	p2ld a, b;
};

int cou;
pairCoor p[3];
pii po;
int tc;

inline double calDistance(const p2ld &a, const p2ld &b) {
	return sqrt(p(b.first - a.first) + p(b.second - a.second));
}

// giải phương trình đường thẳng
inline pdd solveTQE2H(const pairCoor &pc, segment &mySegmet) {
	double a = pc.b.second - pc.a.second;
	double b = pc.b.first - pc.a.first;

	if (!a) {
		mySegmet.a = 0, mySegmet.b = 1, mySegmet.c = -pc.a.second;
		return make_pair(0, 1);
	}

	if (!b) {
		mySegmet.a = 1, mySegmet.b = 0, mySegmet.c = -pc.a.first;
		return make_pair(1, 0);
	}

	mySegmet.a = a, mySegmet.b = -b, mySegmet.c = ((-pc.a.first*a) - (-pc.a.second*b));
	return make_pair(a, -b);
}

// tìm 2 cạnh có cùng 1 điểm chung
inline pii findSamePoint() {
	pii res = { -1, -1 };

	forn(i, 3, 0) {
		forn(j, 3, i + 1) {
			if (p[i].a == p[j].a || p[i].a == p[j].b) {
				res = { i, j };
				++cou;
			}

			if (p[i].b == p[j].a || p[i].b == p[j].b) {
				res = { i, j };
				++cou;
			}
		}
	}

	return cou == 1 ? res : make_pair(-1, -1);
}

inline bool isAc() {
	int thirdSegment = 3 - po.first - po.second;

	if ((firstSegment.a*p[thirdSegment].a.first + firstSegment.b*p[thirdSegment].a.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].b.first + secondSegment.b*p[thirdSegment].b.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].a);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].a);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].b);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].b);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 < f && f2 < f && s1 < s && s2 < s) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	if ((firstSegment.a*p[thirdSegment].b.first + firstSegment.b*p[thirdSegment].b.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].a.first + secondSegment.b*p[thirdSegment].a.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].b);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].b);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].a);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].a);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 < f && f2 < f && s1 < s && s2 < s) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	return false;
}

// tính số đo góc kẹp giữa
inline double calAngleBetween() {
	p2ld A = solveTQE2H(p[po.first], firstSegment);
	p2ld B = solveTQE2H(p[po.second], secondSegment);

	ld dot = fabs(A.first*B.first + A.second*B.second);
	ld d1 = sqrt(p(A.first) + p(A.second));
	ld d2 = sqrt(p(B.first) + p(B.second));

	return acos(dot / (d1*d2))*(180.0 / pi);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	cin >> tc;

	while (tc--) {
		cou = 0;

		forn(i, 3, 0) {
			cin >> p[i].a.first >> p[i].a.second >> p[i].b.first >> p[i].b.second;
		}

		po = findSamePoint();

		if (3 - po.first - po.second <= 2) {
			double angleBetween = calAngleBetween();

			if (angleBetween <= 90 && angleBetween > 0) {
				if (isAc()) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
//============================================================================================

struct segment {
	ld a = 0, b = 0, c = 0;
} firstSegment, secondSegment;

struct pairCoor {
	p2ld a, b;
};

int cou;
pairCoor p[3];
pii po;
int tc;

inline double calDistance(const p2ld &a, const p2ld &b) {
	return sqrt(p(b.first - a.first) + p(b.second - a.second));
}

// giải phương trình đường thẳng
inline pdd solveTQE2H(const pairCoor &pc, segment &mySegmet) {
	double a = pc.b.second - pc.a.second;
	double b = pc.b.first - pc.a.first;

	if (!a && !b) {
		mySegmet.a = 0, mySegmet.b = 0, mySegmet.c = 0;
		return make_pair(0, 0);
	}

	if (!a) {
		mySegmet.a = 0, mySegmet.b = 1, mySegmet.c = -pc.a.second;
		return make_pair(0, 1);
	}

	if (!b) {
		mySegmet.a = 1, mySegmet.b = 0, mySegmet.c = -pc.a.first;
		return make_pair(1, 0);
	}

	mySegmet.a = a, mySegmet.b = -b, mySegmet.c = ((-pc.a.first*a) - (-pc.a.second*b));
	return make_pair(a, -b);
}

// tìm 2 cạnh có cùng 1 điểm chung
inline pii findSamePoint() {
	pii res = { -1, -1 };

	forn(i, 3, 0) {
		forn(j, 3, i + 1) {
			if (p[i].a == p[j].a || p[i].a == p[j].b) {
				res = { i, j };
				++cou;
			}

			if (p[i].b == p[j].a || p[i].b == p[j].b) {
				res = { i, j };
				++cou;
			}
		}
	}

	return cou == 1 ? res : make_pair(-1, -1);
}

inline bool isAc() {
	int thirdSegment = 3 - po.first - po.second;

	if ((firstSegment.a*p[thirdSegment].a.first + firstSegment.b*p[thirdSegment].a.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].b.first + secondSegment.b*p[thirdSegment].b.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].a);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].a);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].b);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].b);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 + f2 <= f + 0.0000001 && s1 + s2 <= s + 0.0000001) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	if ((firstSegment.a*p[thirdSegment].b.first + firstSegment.b*p[thirdSegment].b.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].a.first + secondSegment.b*p[thirdSegment].a.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].b);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].b);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].a);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].a);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 + f2 <= f + 0.0000001 && s1 + s2 <= s + 0.0000001) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	return false;
}

// tính số đo góc kẹp giữa
inline double calAngleBetween() {
	p2ld A = solveTQE2H(p[po.first], firstSegment);
	p2ld B = solveTQE2H(p[po.second], secondSegment);

	ld dot = fabs(A.first*B.first + A.second*B.second);
	ld d1 = sqrt(p(A.first) + p(A.second));
	ld d2 = sqrt(p(B.first) + p(B.second));

	return acos(dot / (d1*d2))*(180.0 / pi);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	cin >> tc;

	while (tc--) {
		cou = 0;

		forn(i, 3, 0) {
			cin >> p[i].a.first >> p[i].a.second >> p[i].b.first >> p[i].b.second;
		}

		po = findSamePoint();

		if (3 - po.first - po.second <= 2) {
			double angleBetween = calAngleBetween();

			if (angleBetween <= 90 && angleBetween > 0,0000001) {
				if (isAc()) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	if (AB && AC && BC && AB + AC > BC && AB + BC > AC && BC + AC > AB) {
		double deg = acos((p(AB) + p(AC) - p(BC)) / (2 * AB*AC))*(180.0 / pi);

		return 0 < deg && deg <= 90;
	}

	return false;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(A, p[in].second);

	return (d && d1 && d2 && (d - (d1 + d2)) >= 0  && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}
			else if (p[sp.first].second == p[sp.second].second) {
				swap(p[sp.first].first, p[sp.first].second);
				swap(p[sp.second].first, p[sp.second].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
//============================================================================================

struct segment {
	ld a = 0, b = 0, c = 0;
} firstSegment, secondSegment;

struct pairCoor {
	p2ld a, b;
};

int cou;
pairCoor p[3];
pii po;
int tc;

inline double calDistance(const p2ld &a, const p2ld &b) {
	return sqrt(p(b.first - a.first) + p(b.second - a.second));
}

// giải phương trình đường thẳng
inline pdd solveTQE2H(const pairCoor &pc, segment &mySegmet) {
	double a = pc.b.second - pc.a.second;
	double b = pc.b.first - pc.a.first;

	if (!a) {
		mySegmet.a = 0, mySegmet.b = 1, mySegmet.c = -pc.a.second;
		return make_pair(0, 1);
	}

	if (!b) {
		mySegmet.a = 1, mySegmet.b = 0, mySegmet.c = -pc.a.first;
		return make_pair(1, 0);
	}

	mySegmet.a = a, mySegmet.b = -b, mySegmet.c = ((-pc.a.first*a) - (-pc.a.second*b));
	return make_pair(a, -b);
}

// tìm 2 cạnh có cùng 1 điểm chung
inline pii findSamePoint() {
	pii res = { -1, -1 };

	forn(i, 3, 0) {
		forn(j, 3, i + 1) {
			if (p[i].a == p[j].a || p[i].a == p[j].b) {
				res = { i, j };
				++cou;
			}

			if (p[i].b == p[j].a || p[i].b == p[j].b) {
				res = { i, j };
				++cou;
			}
		}
	}

	return cou == 1 ? res : make_pair(-1, -1);
}

inline bool isAc() {
	int thirdSegment = 3 - po.first - po.second;

	if ((firstSegment.a*p[thirdSegment].a.first + firstSegment.b*p[thirdSegment].a.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].b.first + secondSegment.b*p[thirdSegment].b.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].a);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].a);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].b);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].b);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 + f2 <= f + 0.0000001 && s1 + s2 <= s + 0.0000001) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	if ((firstSegment.a*p[thirdSegment].b.first + firstSegment.b*p[thirdSegment].b.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].a.first + secondSegment.b*p[thirdSegment].a.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].b);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].b);
		ld f = calDistance(p[po.first].a, p[po.first].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].a);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].a);
		ld s = calDistance(p[po.second].a, p[po.second].b);

		if (f1 + f2 <= f + 0.0000001 && s1 + s2 <= s + 0.0000001) {
			if (f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4) {
				return true;
			}
		}
	}

	return false;
}

// tính số đo góc kẹp giữa
inline double calAngleBetween() {
	p2ld A = solveTQE2H(p[po.first], firstSegment);
	p2ld B = solveTQE2H(p[po.second], secondSegment);

	ld dot = fabs(A.first*B.first + A.second*B.second);
	ld d1 = sqrt(p(A.first) + p(A.second));
	ld d2 = sqrt(p(B.first) + p(B.second));

	return acos(dot / (d1*d2))*(180.0 / pi);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	cin >> tc;

	while (tc--) {
		cou = 0;

		forn(i, 3, 0) {
			cin >> p[i].a.first >> p[i].a.second >> p[i].b.first >> p[i].b.second;
		}

		po = findSamePoint();

		if (3 - po.first - po.second <= 2) {
			double angleBetween = calAngleBetween();

			if (angleBetween <= 90 && angleBetween > 0) {
				if (isAc()) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
//============================================================================================

struct segment {
	double a = 0, b = 0, c = 0;
} firstSegment, secondSegment;

struct pairCoor {
	pdd a, b;
};

pdd sp;
pairCoor p[3];
pii po;
int tc;

inline double calDistance(const pdd &a, const pdd &b) {
	return sqrt(p(b.first - a.first) + p(b.second - a.second));
}

// giải phương trình đường thẳng
inline pdd solveTQE2H(const pairCoor &pc, segment mySegmet) {
	double a = pc.b.second - pc.a.second;
	double b = pc.b.first - pc.a.first;

	if (!a) {
		mySegmet.a = 0, mySegmet.b = 1, mySegmet.c = -pc.a.second;
		return make_pair(0, 1);
	}

	if (!b) {
		mySegmet.a = 1, mySegmet.b = 0, mySegmet.c = -pc.a.first;
		return make_pair(1, 0);
	}

	mySegmet.a = a, mySegmet.b = -b, mySegmet.c = ((-pc.a.first*(pc.b.second - pc.a.second)) - (-pc.a.second*(pc.b.first - pc.a.first)));
	return make_pair(a, -b);
}

// tìm 2 cạnh có cùng 1 điểm chung
inline pii findSamePoint() {
	forn(i, 3, 0) {
		forn(j, 3, i + 1) {
			if (p[i].a == p[j].a || p[i].a == p[j].b) {
				sp = p[i].a;
				return make_pair(i, j);
			}

			if (p[i].b == p[j].a || p[i].b == p[j].b) {
				sp = p[i].b;
				return make_pair(i, j);
			}
		}
	}

	return make_pair(-1, -1);
}

inline bool isAc() {
	int thirdSegment = 3 - po.first - po.second;

	if ((firstSegment.a*p[thirdSegment].a.first + firstSegment.b*p[thirdSegment].a.second + firstSegment.c == 0 &&
		secondSegment.a*p[thirdSegment].b.first + secondSegment.b*p[thirdSegment].b.second + secondSegment.c == 0)) {
		double first = calDistance(sp, p[thirdSegment].a);
		double second = calDistance(sp, p[thirdSegment].b);
		double third = calDistance(p[thirdSegment].a, p[thirdSegment].b);

		return third/first >= 0.25 && third/second >= 0.25;
	}

	if ((firstSegment.a*p[thirdSegment].b.first + firstSegment.b*p[thirdSegment].b.second + firstSegment.c == 0 &&
		secondSegment.a*p[thirdSegment].a.first + secondSegment.b*p[thirdSegment].a.second + secondSegment.c == 0)) {
		double first = calDistance(sp, p[thirdSegment].b);
		double second = calDistance(sp, p[thirdSegment].a);
		double third = calDistance(p[thirdSegment].a, p[thirdSegment].b);

		return third / first >= 0.25 && third / second >= 0.25;
	}

	return false;
}

// tính số đo góc kẹp giữa
inline double calAngleBetween() {
	pdd A = solveTQE2H(p[po.first], firstSegment);
	pdd B = solveTQE2H(p[po.second], secondSegment);

	double dot = fabs(A.first*B.first + A.second*B.second);
	double d1 = sqrt(p(A.first) + p(A.second));
	double d2 = sqrt(p(B.first) + p(B.second));

	return acos(dot / (d1*d2))*(180.0/pi);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	cin >> tc;

	while (tc--) {
		forn(i, 3, 0) {
			cin >> p[i].a.first >> p[i].a.second >> p[i].b.first >> p[i].b.second;
		}

		po = findSamePoint();

		if (3 - po.first - po.second <= 2) {
			double angleBetween = calAngleBetween();

			if (angleBetween <= 90 && angleBetween > 0) {
				if (isAc()) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline ld calDistance(const coor &a, const coor &b) {
		return sqrt((ld)p(b.x - a.x) + (ld)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	if (AB && AC && BC && AB + AC > BC) {
		double deg = acos((p(AB) + p(AC) - p(BC)) / (2 * AB*AC))*(180.0 / pi);

		return 0 < deg && deg <= 90;
	}

	return false;
}

inline bool isIntoSegment(int in, const coor &A) {
	ld d = calDistance(p[in].first, p[in].second);
	ld d1 = calDistance(p[in].first, A);
	ld d2 = calDistance(A, p[in].second);

	return (d && d1 && d2 && d + 0.00001 >= d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}
			else if (p[sp.first].second == p[sp.second].second) {
				swap(p[sp.first].first, p[sp.first].second);
				swap(p[sp.second].first, p[sp.second].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline ld calDistance(const coor &a, const coor &b) {
		return sqrt((ld)p(b.x - a.x) + (ld)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	if (AB && AC && BC && AB + AC > BC && AB + BC > AC && AC + BC > AB) {
		double deg = acos((p(AB) + p(AC) - p(BC)) / (2 * AB*AC))*(180.0 / pi);

		return 0 < deg && deg <= 90;
	}

	return false;
}

inline bool isIntoSegment(int in, const coor &A) {
	if (p[in].first == A || p[in].second == A) {
		return false;
	}

	ld d = calDistance(p[in].first, p[in].second);
	ld d1 = calDistance(p[in].first, A);
	ld d2 = calDistance(A, p[in].second);

	return (d && d1 && d2 && d + 0.00001 >= d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}
			else if (p[sp.first].second == p[sp.second].second) {
				swap(p[sp.first].first, p[sp.first].second);
				swap(p[sp.second].first, p[sp.second].second);
			}

			if (p[sp.first].second == p[sp.second].second) {
				cout << "NO" << endl;
				continue;
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	if (AB && AC && BC && AB + AC > BC) {
		double deg = acos((p(AB) + p(AC) - p(BC)) / (2 * AB*AC))*(180.0 / pi);

		return 0 < deg && deg <= 90;
	}

	return false;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d && d1 && d2 && d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}
			else if (p[sp.first].second == p[sp.second].second) {
				swap(p[sp.first].first, p[sp.first].second);
				swap(p[sp.second].first, p[sp.second].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	return AB && AC && BC && AB + AC > BC;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d && d1 && d2 && d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}
			else if (p[sp.first].second == p[sp.second].second) {
				swap(p[sp.first].first, p[sp.first].second);
				swap(p[sp.second].first, p[sp.second].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ld x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt(p(b.x - a.x) + p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	return AB + AC > BC;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline ld calDistance(const coor &a, const coor &b) {
		return sqrt((ld)p(b.x - a.x) + (ld)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	if (AB && AC && BC && AB + AC > BC && AB + BC > AC && BC + AC > AB) {
		double deg = acos((p(AB) + p(AC) - p(BC)) / (2 * AB*AC))*(180.0 / pi);

		return 0 < deg && deg <= 90;
	}

	return false;
}

inline bool isIntoSegment(int in, const coor &A) {
	ld d = calDistance(p[in].first, p[in].second);
	ld d1 = calDistance(p[in].first, A);
	ld d2 = calDistance(A, p[in].second);

	return (d && d1 && d2 && d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}
			else if (p[sp.first].second == p[sp.second].second) {
				swap(p[sp.first].first, p[sp.first].second);
				swap(p[sp.second].first, p[sp.second].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}

	friend inline pair<ll, ll> calVector(const coor &A, const coor &B) {
		return{ B.x - A.x, B.y - A.y };
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	p2ll AB = calVector(p[sp.first].first, p[sp.first].second);
	p2ll CD = calVector(p[sp.second].first, p[sp.second].second);
	double head = (AB.first*CD.first + AB.second*CD.second);
	double bot = sqrt(AB.first*AB.first*1.0 + AB.second*AB.second*1.0) * sqrt(CD.first*CD.first*1.0 + CD.second*CD.second*1.0);
	double deg = acos(fabs(head / bot))*(180.0 / pi);

	return deg > 0 && deg <= 90;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}

				if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline ld calDistance(const coor &a, const coor &b) {
		return sqrt((ld)p(b.x - a.x) + (ld)p(b.y - a.y));
	}

	friend inline ll ratioDist(const coor &a, const coor &b) {
		return p(b.x - a.x) + p(b.y - a.y);
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	if (AB && AC && BC && AB + AC > BC) {
		double deg = acos((p(AB) + p(AC) - p(BC)) / (2 * AB*AC))*(180.0 / pi);

		return 0 < deg && deg <= 90;
	}

	return false;
}

inline bool isIntoSegment(int in, const coor &A) {
	if (p[in].first == A || p[in].second == A) {
		return false;
	}

	ll x1 = p[in].first.x - A.x, x2 = A.x - p[in].second.x;
	ll y1 = p[in].first.y - A.y, y2 = A.y - p[in].second.y;

	if (x1*y2 != x2*y1) {
		return false;
	}

	ll d1 = ratioDist(p[in].first, A);
	ll d2 = ratioDist(A, p[in].second);
	ll d = ratioDist(p[in].first, p[in].second);
	if (d1 + d2 >= d) {
		return false;
	}

	if (((d1*1.0) / d2) < 0.0625 || 16.0 < ((d1*1.0) / d2)) {
		return false;
	}

	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}
			else if (p[sp.first].second == p[sp.second].second) {
				swap(p[sp.first].first, p[sp.first].second);
				swap(p[sp.second].first, p[sp.second].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}

	friend inline pair<ll, ll> calVector(const coor &A, const coor &B) {
		return{ B.x - A.x, B.y - A.y };
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	p2ll AB = calVector(p[sp.first].first, p[sp.first].second);
	p2ll CD = calVector(p[sp.second].first, p[sp.second].second);
	double head = (AB.first*CD.first + AB.second*CD.second);
	double bot = sqrt(AB.first*AB.first*1.0 + AB.second*AB.second*1.0) * sqrt(CD.first*CD.first*1.0 + CD.second*CD.second*1.0);
	double deg = acos(fabs(head / bot))*(180.0 / pi);

	return deg > 0 && deg <= 90;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d == d1 + d2 && min(d1, d2)*4 >= max(d1, d2));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}

				if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
//============================================================================================

struct segment {
	ld a = 0, b = 0, c = 0;
} firstSegment, secondSegment;

struct pairCoor {
	p2ld a, b;
};

int cou;
pairCoor p[3];
pii po;
int tc;

inline double calDistance(const p2ld &a, const p2ld &b) {
	return sqrt(p(b.first - a.first) + p(b.second - a.second));
}

// giải phương trình đường thẳng
inline pdd solveTQE2H(const pairCoor &pc, segment &mySegmet) {
	double a = pc.b.second - pc.a.second;
	double b = pc.b.first - pc.a.first;

	if (!a) {
		mySegmet.a = 0, mySegmet.b = 1, mySegmet.c = -pc.a.second;
		return make_pair(0, 1);
	}

	if (!b) {
		mySegmet.a = 1, mySegmet.b = 0, mySegmet.c = -pc.a.first;
		return make_pair(1, 0);
	}

	mySegmet.a = a, mySegmet.b = -b, mySegmet.c = ((-pc.a.first*a) - (-pc.a.second*b));
	return make_pair(a, -b);
}

// tìm 2 cạnh có cùng 1 điểm chung
inline pii findSamePoint() {
	pii res = { -1, -1 };

	forn(i, 3, 0) {
		forn(j, 3, i + 1) {
			if (p[i].a == p[j].a || p[i].a == p[j].b) {
				res = { i, j};
				++cou;
			}

			if (p[i].b == p[j].a || p[i].b == p[j].b) {
				res = { i, j };
				++cou;
			}
		}
	}

	return cou == 1 ? res : make_pair(-1, -1);
}

inline bool isAc() {
	int thirdSegment = 3 - po.first - po.second;

	if ((firstSegment.a*p[thirdSegment].a.first + firstSegment.b*p[thirdSegment].a.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].b.first + secondSegment.b*p[thirdSegment].b.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].a);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].a);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].b);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].b);

		return f1/f2 >= 0.25 && f1/f2 <= 4 && s1/s2 >= 0.25 && s1/s2 <= 4;
	}

	if ((firstSegment.a*p[thirdSegment].b.first + firstSegment.b*p[thirdSegment].b.second + firstSegment.c <= 0.0000001 &&
		secondSegment.a*p[thirdSegment].a.first + secondSegment.b*p[thirdSegment].a.second + secondSegment.c <= 0.0000001)) {
		ld f1 = calDistance(p[po.first].a, p[thirdSegment].b);
		ld f2 = calDistance(p[po.first].b, p[thirdSegment].b);
		ld s1 = calDistance(p[po.second].a, p[thirdSegment].a);
		ld s2 = calDistance(p[po.second].b, p[thirdSegment].a);

		return f1 / f2 >= 0.25 && f1 / f2 <= 4 && s1 / s2 >= 0.25 && s1 / s2 <= 4;
	}

	return false;
}

// tính số đo góc kẹp giữa
inline double calAngleBetween() {
	p2ld A = solveTQE2H(p[po.first], firstSegment);
	p2ld B = solveTQE2H(p[po.second], secondSegment);

	ld dot = fabs(A.first*B.first + A.second*B.second);
	ld d1 = sqrt(p(A.first) + p(A.second));
	ld d2 = sqrt(p(B.first) + p(B.second));

	return acos(dot / (d1*d2))*(180.0/pi);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	cin >> tc;

	while (tc--) {
		cou = 0;

		forn(i, 3, 0) {
			cin >> p[i].a.first >> p[i].a.second >> p[i].b.first >> p[i].b.second;
		}

		po = findSamePoint();

		if (3 - po.first - po.second <= 2) {
			double angleBetween = calAngleBetween();

			if (angleBetween <= 90 && angleBetween > 0) {
				if (isAc()) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	ld AB = calDistance(p[sp.first].first, p[sp.first].second);
	ld AC = calDistance(p[sp.second].first, p[sp.second].second);
	ld BC = calDistance(p[sp.first].second, p[sp.second].second);

	return AB && AC && BC && AB + AC > BC;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d && d1 && d2 && d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		if (p[0].first == p[0].second || p[1].first == p[1].second || p[2].first == p[2].second) {
			cout << "NO" << endl;
			continue;
		}

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (p[sp.first].first == p[sp.second].second) {
				swap(p[sp.second].first, p[sp.second].second);
			}
			else if (p[sp.first].second == p[sp.second].first) {
				swap(p[sp.first].first, p[sp.first].second);
			}

			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}
				else if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}


#pragma warning(disable:4996)
#include <bits\stdc++.h>
using namespace std;

//=============================================================================================
const double pi = 3.14159265359;
#define p(a) ((a) * (a))
#define forn(i, n, s) for (int i = s; i < n; ++i)
#define forp(i, n, s) for (int i = s; i > n; --i)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> p2ll;
typedef pair<string, int> psi;
typedef pair<ld, ld> p2ld;
typedef pair<char, char> pcc;
//=============================================================================================

struct coor {
	ll x, y;

	friend istream &operator >> (istream &is, coor &A) {
		is >> A.x >> A.y;
		return is;
	}

	friend inline bool operator== (const coor &A, const coor &B) {
		return A.x == B.x && A.y == B.y;
	}

	friend inline double calDistance(const coor &a, const coor &b) {
		return sqrt((double)p(b.x - a.x) + (double)p(b.y - a.y));
	}

	friend inline pair<ll, ll> calVector(const coor &A, const coor &B) {
		return{ B.x - A.x, B.y - A.y };
	}
};

pair<coor, coor> p[3];

inline pii findSamePoints() {
	forn(i, 2, 0) {
		forn(j, 3, i + 1) {
			if (p[i].first == p[j].first || p[i].first == p[j].second || p[i].second == p[j].first || p[i].second == p[j].second) {
				return{ i, j };
			}
		}
	}

	return{ -1, -1 };
}

inline bool calAngleBetween(const pii &sp) {
	p2ll AB = calVector(p[sp.first].first, p[sp.first].second);
	p2ll CD = calVector(p[sp.second].first, p[sp.second].second);
	double head = (AB.first*CD.first + AB.second*CD.second);
	double bot = sqrt(AB.first*AB.first*1.0 + AB.second*AB.second*1.0) * sqrt(CD.first*CD.first*1.0 + CD.second*CD.second*1.0);
	double deg = acos(fabs(head / bot))*(180.0 / pi);

	return deg > 0 && deg <= 90;
}

inline bool isIntoSegment(int in, const coor &A) {
	double d = calDistance(p[in].first, p[in].second);
	double d1 = calDistance(p[in].first, A);
	double d2 = calDistance(p[in].second, A);

	return (d == d1 + d2 && 0.25 <= d1 / d2 && d1 / d2 <= 4);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);

	int tc;

	cin >> tc;

	while (tc--) {
		cin >> p[0].first >> p[0].second;
		cin >> p[1].first >> p[1].second;
		cin >> p[2].first >> p[2].second;

		pii sp = findSamePoints();

		if (sp.first != -1 && sp.second != -1) {
			if (calAngleBetween(sp)) {
				int it = 3 - sp.first - sp.second;

				if (isIntoSegment(sp.first, p[it].first) && isIntoSegment(sp.second, p[it].second)) {
					cout << "YES" << endl;
					continue;
				}

				if (isIntoSegment(sp.first, p[it].second) && isIntoSegment(sp.second, p[it].first)) {
					cout << "YES" << endl;
					continue;
				}
			}
		}

		cout << "NO" << endl;
	}

	return 0;
}