#include <bits/stdc++.h>
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pushf push_front
#define popf pop_front
#define pushb push_back
#define popb pop_back
// caution: MLE → comment below and use explicit "ll"
#define int ll

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pii>;
using vll = vector<pll>;
template <typename T> using pqmax = priority_queue<T>;
template <typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;

template <typename T> T inf() {return numeric_limits<T>::max()/2;}
template <typename T> inline T sq(T x){return x*x;}
template<typename A, typename B>
ostream& operator <<(ostream& os, const pair<A, B>& x) {
	os << x.fst << ' ' << x.snd; return os;
}
template<typename A, typename B>
istream& operator >>(istream& is, pair<A, B>& x) {
	is >> x.fst >> x.snd; return is;
}
template<typename A, typename B>
pair<A, B> operator +(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst+b.fst, a.snd+b.snd);
}
template<typename A, typename B>
pair<A, B> operator -(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst-b.fst, a.snd-b.snd);
}
template <typename T> auto cinvec(int n, int base=0) {
	vector<T> v(n+base);
	for (int i = base; i < sz(v); ++i) cin >> v[i];
	return v;
}
template <typename T> void memset(T& x, int val) {
	memset(x, val, sizeof(x));
}
template <typename T> void sort(T& x, int base=0) {
	sort(x.begin()+base, x.end());
}
template <typename T> void reverse(T& x, int base=0) {
	reverse(x.begin()+base, x.end());
}
template <typename T> void uniq(T& x, int base=0) {
	x.erase(unique(x.begin()+base, x.end()), x.end());
}
template <typename T> int lbpos(T& x, int val, int base=0) {
	return lower_bound(x.begin()+base, x.end(), val) - x.begin();
}
template <typename T> ll getsum(vector<T>& x, int base=0) {
	ll ret = 0;
	for (int i = base; i < sz(x); ++i) ret += x[i];
	return ret;
}
template <typename T> T getmax(vector<T>& x, int base=0) {
	return *max_element(x.begin()+base, x.end());
}
template <typename T> T getmin(vector<T>& x, int base=0) {
	return *min_element(x.begin()+base, x.end());
}
ll rand(ll mn, ll mx=LLONG_MAX/2){
	static mt19937 rng(time(0)^ll(new int));
	return uniform_int_distribution<ll>(mn, mx-1)(rng);
}

/***********************************************************************************/
#define MULTITEST 1
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
const ll MOD = 998244353;
const ll MAX = 3002;

/***********************************************************************************/
const double PI = 2*acos(0.0);
template <typename T>
bool equal(T a, T b) {
	if constexpr(is_same_v<T, double>) {
		double diff = fabs(a-b);
		if (diff < 1e-10) return true;
		return diff < 1e-8 * max(fabs(a), fabs(b));
	}
	return a==b;
}

template <typename T>
struct VT {
	T x, y;
	VT(T _x=0, T _y=0) : x(_x),y(_y){}
	bool operator ==(const VT& rhs) const {
		return equal(x, rhs.x) && equal(y, rhs.y);
	}
	bool operator <(const VT& rhs) const {
		if (*this == rhs) return false;
		return !equal(x, rhs.x) ? x < rhs.x : y < rhs.y;
	}
	bool operator <=(const VT& rhs) const {
		return *this == rhs || *this < rhs;
	}
	VT operator +(const VT& rhs) const {
		return VT(x+rhs.x, y+rhs.y);
	}
	VT operator -(const VT& rhs) const {
		return VT(x-rhs.x, y-rhs.y);
	}
	VT operator -() const {
		return VT(-x, -y);
	}
	VT operator *(T rhs) const {
		return VT(x*rhs, y*rhs);
	}
	T norm() const { // 벡터의 크기 반환, 정수형의 경우 크기 제곱
		if constexpr(is_same_v<T, double>) return hypot(x, y);
		return sq(x)+sq(y);
	}
	VT normalize() const { // 현재 벡터의 방향을 갖는 단위벡터 반환
		if (equal(norm(), (T)0)) return *this;
		T div = 0;
		if constexpr(is_same_v<T, double>) div = norm();
		else div = gcd(x, y);
		return VT(x/div, y/div);
	}
	T dot(const VT& rhs) const { // 내적
		return x*rhs.x + y*rhs.y;
	}
	T cross(const VT& rhs) const { // 외적
		return x*rhs.y - y*rhs.x;
	}
	// 현재 벡터를 rhs에 사영한 벡터를 반환
	VT project(const VT& rhs) const {
		if constexpr(is_same_v<T, double>) {
			VT r = rhs.normalize();
			return r * r.dot(*this);
		}
		else {assert(0); return VT(0, 0);}
	}
};
template<typename T>
ostream& operator <<(ostream& os, const VT<T>& p) {
	os << p.x << ' ' << p.y; return os;
}
template<typename T>
istream& operator >>(istream& is, VT<T>& p) {
	is >> p.x >> p.y; return is;
}

template <typename T>
T ccw(VT<T> a, VT<T> b, VT<T> c) {
	return (b-a).cross(c-a);
}
// 점 p,a,b가 일직선상에 있을 때 p가 [a, b]에 있는지 본다
template <typename T>
bool inRange(VT<T> p, VT<T> a, VT<T> b) {
	if (b < a) swap(a, b);
	return a <= p && p <= b;
}

// ab를 포함하는 직선과 cd를 포함하는 직선의 교점을 구해 x에 저장
// 교점이 존재하면 참, 존재하지 않으면(평행/겹침) 거짓을 반환
template <typename T>
bool lineIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		double det = (b-a).cross(d-c);
		if (equal(det, (T)0)) return false;
		x = a + (b-a) * ((c-a).cross(d-c) / det);
		return true;
	}
	else {assert(0); return false;}
}

// ab선분과 cd선분이 겹치는지 여부를 반환 (오버플로우 주의)
template <typename T>
bool segIntersect(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	T tmp1 = ccw(a, b, c), tmp2 = ccw(a, b, d);
	T tmp3 = ccw(c, d, a), tmp4 = ccw(c, d, b);
	T ab = 0, cd = 0;
	if constexpr(is_same_v<T, double>) {
		ab = tmp1*tmp2; cd = tmp3*tmp4;
	}
	else {
		if (tmp1 != 0 && tmp2 != 0) {
			tmp1 /= abs(tmp1); tmp2 /= abs(tmp2);
			ab = tmp1*tmp2;
		}
		if (tmp3 != 0 && tmp4 != 0) {
			tmp3 /= abs(tmp3); tmp4 /= abs(tmp4);
			cd = tmp3*tmp4;
		}
	}
	// 두 선분이 한 직선 위에 있거나 끝 점이 겹치는 경우
	if (equal(ab, (T)0) && equal(cd, (T)0)) {
		if (b < a) swap(a, b);
		if (d < c) swap(c, d);
		return !(d < a || b < c);
	}
	// 선분에 다른 선분이 접촉한 경우도 고려
	return (equal(ab, (T)0) || ab < 0) &&
		(equal(cd, (T)0) || cd < 0);
}

// ab선분과 cd선분이 겹치는지 여부를 반환
// 겹치는 경우 교점(무한개면 임의의 교점)을 x에 저장
template <typename T>
bool segIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		if (lineIntersection(a, b, c, d, x))
			return inRange(x, a, b) && inRange(x, c, d);
		if (b < a) swap(a, b); if (d < c) swap(c, d);
		if (!equal(ccw(a, b, c), (T)0) || d < a || b < c) return false;
		if (a < c) x = c; else x = a;
		return true;
	}
	else {assert(0); return false;}
}

// 점 p에서 ab직선에 내린 수선의 발을 반환
template <typename T>
VT<T> foot(VT<T> p, VT<T> a, VT<T> b) {
	return a + (p-a).project(b-a);
}

// 점 p에서 ab직선까지의 최소 거리를 반환
template <typename T>
T pointToLine(VT<T> p, VT<T> a, VT<T> b) {
	return (p-foot(p, a, b)).norm();
}

// 점 p에서 ab선분까지의 최소 거리를 반환
template <typename T>
T pointToSeg(VT<T> p, VT<T> a, VT<T> b) {
	VT h = foot(p, a, b);
	if (inRange(h, a, b)) return (p-h).norm();
	return min((p-a).norm(), (p-b).norm());
}

// ab선분에서 cd선분까지의 최소 거리를 반환
template <typename T>
T segToSeg(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	if (segIntersect(a, b, c, d)) return (T)0;
	return min({pointToSeg(a, c, d), pointToSeg(b, c, d),
		pointToSeg(c, a, b), pointToSeg(d, a, b)});
}

// 다각형 p의 넓이를 반환, 정수형의 경우 2로 나누지 않음
template <typename T>
T area(const vector<VT<T>>& p) {
	T ret = 0;
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		ret += p[i].cross(p[j]);
	}
	if constexpr(is_same_v<T, double>) return fabs(ret)/2;
	else return abs(ret);
}

// 점 q가 다각형 p의 경계에 위치하는지 여부를 반환
template <typename T>
bool onBound(const vector<VT<T>>& p, VT<T> q) {
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		if (equal(ccw(q, p[i], p[j]), (T)0) &&
			inRange(q, p[i], p[j]))
			return true;
	}
	return false;
}

// 점 q가 다각형 p의 내부에 있는지 외부에 있는지를 판별
template <typename T>
bool inside(const vector<VT<T>>& p, VT<T> q) {
	if constexpr(is_same_v<T, double>) {
		if (onBound(p, q)) return false;
		int cross = 0, n = sz(p);
		for (int i = 0; i < n; ++i) {
			int j = (i+1)%n;
			if ((!equal(p[i].y, q.y) && p[i].y > q.y) !=
				(!equal(p[j].y, q.y) && p[j].y > q.y)) {
				double atX = (q.y - p[i].y) * (p[j].x - p[i].x) /
					(p[j].y - p[i].y) + p[i].x;
				if (q.x < atX) ++cross;
			}
		}
		return cross%2 > 0;
	}
	else {assert(0); return false;}
}

bool isA(VT<int> from, VT<int> to1, VT<int> to2, VT<int> a, VT<int> b) {
	// 1. from-to1, from-to2의 각도
	if ((to1-from).cross(to2-from) == 0) return false;
	if ((to1-from).dot(to2-from) < 0) return false;

	// 2. ab선분은 from-to1, from-to2에 걸침
	int cval1 = ccw(from, to1, a), cval2 = ccw(from, to1, b);
	if (cval1 != 0 && cval2 != 0) return false;
	if (cval2 == 0) swap(a, b);

	if (!inRange(a, from, to1)) return false;
	//assert(segIntersect(from, to1, a, b));
	int dist1 = (a-from).norm(), dist2 = (a-to1).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;

	if (!inRange(b, from, to2)) return false;
	//assert(segIntersect(from, to2, a, b));
	dist1 = (b-from).norm(); dist2 = (b-to2).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;
	return true;
}

void solve(int tc) {
	VT<int> p[3][2];
	for (int i = 0; i < 3; ++i) {
		cin >> p[i][0] >> p[i][1];
	}
	bool valid = false;
	for (int i = 0; i < 3; ++i)
		for (int j = i+1; j < 3; ++j) {
			int k = 3-i-j;
			for (int x = 0; x < 2; ++x)
				for (int y = 0; y < 2; ++y)
					if (p[i][x] == p[j][y]) {
						valid |= isA(p[i][x], p[i][1-x], p[j][1-y], p[k][0], p[k][1]);
					}
		}
	cout << (valid ? "YES" : "NO") << '\n';
}

/***********************************************************************************/
signed main(signed argc, char *argv[]) {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(11);
	bool mult = (MULTITEST && !(argc == 2 && (string)argv[1] == "test"));
	int T = 1; if (mult) cin >> T;
	for (int tc = 1; tc <= T; ++tc) solve(tc);
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pushf push_front
#define popf pop_front
#define pushb push_back
#define popb pop_back
// caution: MLE → comment below and use explicit "ll"
#define int ll

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pii>;
using vll = vector<pll>;
template <typename T> using pqmax = priority_queue<T>;
template <typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;

template <typename T> T inf() {return numeric_limits<T>::max()/2;}
template <typename T> inline T sq(T x){return x*x;}
template<typename A, typename B>
ostream& operator <<(ostream& os, const pair<A, B>& x) {
	os << x.fst << ' ' << x.snd; return os;
}
template<typename A, typename B>
istream& operator >>(istream& is, pair<A, B>& x) {
	is >> x.fst >> x.snd; return is;
}
template<typename A, typename B>
pair<A, B> operator +(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst+b.fst, a.snd+b.snd);
}
template<typename A, typename B>
pair<A, B> operator -(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst-b.fst, a.snd-b.snd);
}
template <typename T> auto cinvec(int n, int base=0) {
	vector<T> v(n+base);
	for (int i = base; i < sz(v); ++i) cin >> v[i];
	return v;
}
template <typename T> void memset(T& x, int val) {
	memset(x, val, sizeof(x));
}
template <typename T> void sort(T& x, int base=0) {
	sort(x.begin()+base, x.end());
}
template <typename T> void reverse(T& x, int base=0) {
	reverse(x.begin()+base, x.end());
}
template <typename T> void uniq(T& x, int base=0) {
	x.erase(unique(x.begin()+base, x.end()), x.end());
}
template <typename T> int lbpos(T& x, int val, int base=0) {
	return lower_bound(x.begin()+base, x.end(), val) - x.begin();
}
template <typename T> ll getsum(vector<T>& x, int base=0) {
	ll ret = 0;
	for (int i = base; i < sz(x); ++i) ret += x[i];
	return ret;
}
template <typename T> T getmax(vector<T>& x, int base=0) {
	return *max_element(x.begin()+base, x.end());
}
template <typename T> T getmin(vector<T>& x, int base=0) {
	return *min_element(x.begin()+base, x.end());
}
ll rand(ll mn, ll mx=LLONG_MAX/2){
	static mt19937 rng(time(0)^ll(new int));
	return uniform_int_distribution<ll>(mn, mx-1)(rng);
}

/***********************************************************************************/
#define MULTITEST 1
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
const ll MOD = 998244353;
const ll MAX = 3002;

/***********************************************************************************/
const double PI = 2*acos(0.0);
template <typename T>
bool equal(T a, T b) {
	if constexpr(is_same_v<T, double>) {
		double diff = fabs(a-b);
		if (diff < 1e-10) return true;
		return diff < 1e-8 * max(fabs(a), fabs(b));
	}
	return a==b;
}

template <typename T>
struct VT {
	T x, y, id;
	VT(T _x=0, T _y=0) : x(_x),y(_y){}
	bool operator ==(const VT& rhs) const {
		return equal(x, rhs.x) && equal(y, rhs.y);
	}
	bool operator <(const VT& rhs) const {
		if (*this == rhs) return false;
		return !equal(x, rhs.x) ? x < rhs.x : y < rhs.y;
	}
	bool operator <=(const VT& rhs) const {
		return *this == rhs || *this < rhs;
	}
	VT operator +(const VT& rhs) const {
		return VT(x+rhs.x, y+rhs.y);
	}
	VT operator -(const VT& rhs) const {
		return VT(x-rhs.x, y-rhs.y);
	}
	VT operator -() const {
		return VT(-x, -y);
	}
	VT operator *(T rhs) const {
		return VT(x*rhs, y*rhs);
	}
	T norm() const { // 벡터의 크기 반환, 정수형의 경우 크기 제곱
		if constexpr(is_same_v<T, double>) return hypot(x, y);
		return sq(x)+sq(y);
	}
	VT normalize() const { // 현재 벡터의 방향을 갖는 단위벡터 반환
		if (equal(norm(), (T)0)) return *this;
		T div = 0;
		if constexpr(is_same_v<T, double>) div = norm();
		else div = gcd(x, y);
		return VT(x/div, y/div);
	}
	T dot(const VT& rhs) const { // 내적
		return x*rhs.x + y*rhs.y;
	}
	T cross(const VT& rhs) const { // 외적
		return x*rhs.y - y*rhs.x;
	}
	// 현재 벡터를 rhs에 사영한 벡터를 반환
	VT project(const VT& rhs) const {
		if constexpr(is_same_v<T, double>) {
			VT r = rhs.normalize();
			return r * r.dot(*this);
		}
		else {assert(0); return VT(0, 0);}
	}
};
template<typename T>
ostream& operator <<(ostream& os, const VT<T>& p) {
	os << p.x << ' ' << p.y; return os;
}
template<typename T>
istream& operator >>(istream& is, VT<T>& p) {
	is >> p.x >> p.y; return is;
}

template <typename T>
T ccw(VT<T> a, VT<T> b, VT<T> c) {
	return (b-a).cross(c-a);
}
// 점 p,a,b가 일직선상에 있을 때 p가 [a, b]에 있는지 본다
template <typename T>
bool inRange(VT<T> p, VT<T> a, VT<T> b) {
	if (b < a) swap(a, b);
	return a <= p && p <= b;
}

// ab를 포함하는 직선과 cd를 포함하는 직선의 교점을 구해 x에 저장
// 교점이 존재하면 참, 존재하지 않으면(평행/겹침) 거짓을 반환
template <typename T>
bool lineIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		double det = (b-a).cross(d-c);
		if (equal(det, (T)0)) return false;
		x = a + (b-a) * ((c-a).cross(d-c) / det);
		return true;
	}
	else {assert(0); return false;}
}

// ab선분과 cd선분이 겹치는지 여부를 반환 (오버플로우 주의)
template <typename T>
bool segIntersect(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	T tmp1 = ccw(a, b, c), tmp2 = ccw(a, b, d);
	T tmp3 = ccw(c, d, a), tmp4 = ccw(c, d, b);
	T ab = 0, cd = 0;
	if constexpr(is_same_v<T, double>) {
		ab = tmp1*tmp2; cd = tmp3*tmp4;
	}
	else {
		if (tmp1 != 0 && tmp2 != 0) {
			tmp1 /= abs(tmp1); tmp2 /= abs(tmp2);
			ab = tmp1*tmp2;
		}
		if (tmp3 != 0 && tmp4 != 0) {
			tmp3 /= abs(tmp3); tmp4 /= abs(tmp4);
			cd = tmp3*tmp4;
		}
	}
	// 두 선분이 한 직선 위에 있거나 끝 점이 겹치는 경우
	if (equal(ab, (T)0) && equal(cd, (T)0)) {
		if (b < a) swap(a, b);
		if (d < c) swap(c, d);
		return !(d < a || b < c);
	}
	// 선분에 다른 선분이 접촉한 경우도 고려
	return (equal(ab, (T)0) || ab < 0) &&
		(equal(cd, (T)0) || cd < 0);
}

// ab선분과 cd선분이 겹치는지 여부를 반환
// 겹치는 경우 교점(무한개면 임의의 교점)을 x에 저장
template <typename T>
bool segIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		if (lineIntersection(a, b, c, d, x))
			return inRange(x, a, b) && inRange(x, c, d);
		if (b < a) swap(a, b); if (d < c) swap(c, d);
		if (!equal(ccw(a, b, c), (T)0) || d < a || b < c) return false;
		if (a < c) x = c; else x = a;
		return true;
	}
	else {assert(0); return false;}
}

// 점 p에서 ab직선에 내린 수선의 발을 반환
template <typename T>
VT<T> foot(VT<T> p, VT<T> a, VT<T> b) {
	return a + (p-a).project(b-a);
}

// 점 p에서 ab직선까지의 최소 거리를 반환
template <typename T>
T pointToLine(VT<T> p, VT<T> a, VT<T> b) {
	return (p-foot(p, a, b)).norm();
}

// 점 p에서 ab선분까지의 최소 거리를 반환
template <typename T>
T pointToSeg(VT<T> p, VT<T> a, VT<T> b) {
	VT h = foot(p, a, b);
	if (inRange(h, a, b)) return (p-h).norm();
	return min((p-a).norm(), (p-b).norm());
}

// ab선분에서 cd선분까지의 최소 거리를 반환
template <typename T>
T segToSeg(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	if (segIntersect(a, b, c, d)) return (T)0;
	return min({pointToSeg(a, c, d), pointToSeg(b, c, d),
		pointToSeg(c, a, b), pointToSeg(d, a, b)});
}

// 다각형 p의 넓이를 반환, 정수형의 경우 2로 나누지 않음
template <typename T>
T area(const vector<VT<T>>& p) {
	T ret = 0;
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		ret += p[i].cross(p[j]);
	}
	if constexpr(is_same_v<T, double>) return fabs(ret)/2;
	else return abs(ret);
}

// 점 q가 다각형 p의 경계에 위치하는지 여부를 반환
template <typename T>
bool onBound(const vector<VT<T>>& p, VT<T> q) {
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		if (equal(ccw(q, p[i], p[j]), (T)0) &&
			inRange(q, p[i], p[j]))
			return true;
	}
	return false;
}

// 점 q가 다각형 p의 내부에 있는지 외부에 있는지를 판별
template <typename T>
bool inside(const vector<VT<T>>& p, VT<T> q) {
	if constexpr(is_same_v<T, double>) {
		if (onBound(p, q)) return false;
		int cross = 0, n = sz(p);
		for (int i = 0; i < n; ++i) {
			int j = (i+1)%n;
			if ((!equal(p[i].y, q.y) && p[i].y > q.y) !=
				(!equal(p[j].y, q.y) && p[j].y > q.y)) {
				double atX = (q.y - p[i].y) * (p[j].x - p[i].x) /
					(p[j].y - p[i].y) + p[i].x;
				if (q.x < atX) ++cross;
			}
		}
		return cross%2 > 0;
	}
	else {assert(0); return false;}
}

bool isA(VT<int> from, VT<int> to1, VT<int> to2, VT<int> a, VT<int> b) {
	// 1. from-to1, from-to2의 각도
	if ((to1-from).cross(to2-from) == 0) return false;
	if (to1-from.dot(to2-from) < 0) return false;

	// 2. from-to 와 a-b의 교차점
	for (auto to : {to1, to2}) {
		if (!segIntersect(from, to, a, b)) return false;
		// 교차점이 정확히 from-to의 p:q 내분지점에 있는 경우
		bool bound = false;
		for (auto p : {1, 4}) {
			int q = 5-p;
			int crossX = p*to.x + q*from.x;
			int crossY = p*to.y + q*from.y;
			if (crossX%5 || crossY%5) continue;
			crossX /= 5; crossY /= 5;
			if (ccw(a, b, VT<int>(crossX, crossY)) == 0) {
				bound = true; break;
			}
		}
		if (bound) continue;
		VT<double> dfrom(from.x, from.y);
		VT<double> dto(to.x, to.y);
		VT<double> da(a.x, a.y), db(b.x, b.y);
		VT<double> cross;

		assert(segIntersection(dfrom, dto, da, db, cross));
		double dist1 = (dfrom-cross).norm();
		double dist2 = (dto-cross).norm();
		if (equal(dist1, 0.0) || equal(dist2, 0.0)) return false;
		if (dist1 > dist2) swap(dist1, dist2);
		double ratio = dist1/dist2;
		if (ratio < 0.25) return false;
	}
	return true;
}

void solve(int tc) {
	VT<int> p[3][2];
	for (int i = 0; i < 3; ++i) {
		cin >> p[i][0] >> p[i][1];
	}
	bool valid = false;
	for (int i = 0; i < 3; ++i)
		for (int j = i+1; j < 3; ++j) {
			int k = 3-i-j;
			for (int x = 0; x < 2; ++x)
				for (int y = 0; y < 2; ++y)
					if (p[i][x] == p[j][y]) {
						valid |= isA(p[i][x], p[i][1-x], p[j][1-y], p[k][0], p[k][1]);
					}
		}
	cout << (valid ? "YES" : "NO") << '\n';
}

/***********************************************************************************/
signed main(signed argc, char *argv[]) {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(11);
	bool mult = (MULTITEST && !(argc == 2 && (string)argv[1] == "test"));
	int T = 1; if (mult) cin >> T;
	for (int tc = 1; tc <= T; ++tc) solve(tc);
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pushf push_front
#define popf pop_front
#define pushb push_back
#define popb pop_back
// caution: MLE → comment below and use explicit "ll"
#define int ll

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pii>;
using vll = vector<pll>;
template <typename T> using pqmax = priority_queue<T>;
template <typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;

template <typename T> T inf() {return numeric_limits<T>::max()/2;}
template <typename T> inline T sq(T x){return x*x;}
template<typename A, typename B>
ostream& operator <<(ostream& os, const pair<A, B>& x) {
	os << x.fst << ' ' << x.snd; return os;
}
template<typename A, typename B>
istream& operator >>(istream& is, pair<A, B>& x) {
	is >> x.fst >> x.snd; return is;
}
template<typename A, typename B>
pair<A, B> operator +(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst+b.fst, a.snd+b.snd);
}
template<typename A, typename B>
pair<A, B> operator -(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst-b.fst, a.snd-b.snd);
}
template <typename T> auto cinvec(int n, int base=0) {
	vector<T> v(n+base);
	for (int i = base; i < sz(v); ++i) cin >> v[i];
	return v;
}
template <typename T> void memset(T& x, int val) {
	memset(x, val, sizeof(x));
}
template <typename T> void sort(T& x, int base=0) {
	sort(x.begin()+base, x.end());
}
template <typename T> void reverse(T& x, int base=0) {
	reverse(x.begin()+base, x.end());
}
template <typename T> void uniq(T& x, int base=0) {
	x.erase(unique(x.begin()+base, x.end()), x.end());
}
template <typename T> int lbpos(T& x, int val, int base=0) {
	return lower_bound(x.begin()+base, x.end(), val) - x.begin();
}
template <typename T> ll getsum(vector<T>& x, int base=0) {
	ll ret = 0;
	for (int i = base; i < sz(x); ++i) ret += x[i];
	return ret;
}
template <typename T> T getmax(vector<T>& x, int base=0) {
	return *max_element(x.begin()+base, x.end());
}
template <typename T> T getmin(vector<T>& x, int base=0) {
	return *min_element(x.begin()+base, x.end());
}
ll rand(ll mn, ll mx=LLONG_MAX/2){
	static mt19937 rng(time(0)^ll(new int));
	return uniform_int_distribution<ll>(mn, mx-1)(rng);
}

/***********************************************************************************/
#define MULTITEST 1
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
const ll MOD = 998244353;
const ll MAX = 3002;

/***********************************************************************************/
const double PI = 2*acos(0.0);
template <typename T>
bool equal(T a, T b) {
	if constexpr(is_same_v<T, double>) {
		double diff = fabs(a-b);
		if (diff < 1e-10) return true;
		return diff < 1e-8 * max(fabs(a), fabs(b));
	}
	return a==b;
}

template <typename T>
struct VT {
	T x, y;
	VT(T _x=0, T _y=0) : x(_x),y(_y){}
	bool operator ==(const VT& rhs) const {
		return equal(x, rhs.x) && equal(y, rhs.y);
	}
	bool operator <(const VT& rhs) const {
		if (*this == rhs) return false;
		return !equal(x, rhs.x) ? x < rhs.x : y < rhs.y;
	}
	bool operator <=(const VT& rhs) const {
		return *this == rhs || *this < rhs;
	}
	VT operator +(const VT& rhs) const {
		return VT(x+rhs.x, y+rhs.y);
	}
	VT operator -(const VT& rhs) const {
		return VT(x-rhs.x, y-rhs.y);
	}
	VT operator -() const {
		return VT(-x, -y);
	}
	VT operator *(T rhs) const {
		return VT(x*rhs, y*rhs);
	}
	T norm() const { // 벡터의 크기 반환, 정수형의 경우 크기 제곱
		if constexpr(is_same_v<T, double>) return hypot(x, y);
		return sq(x)+sq(y);
	}
	VT normalize() const { // 현재 벡터의 방향을 갖는 단위벡터 반환
		if (equal(norm(), (T)0)) return *this;
		T div = 0;
		if constexpr(is_same_v<T, double>) div = norm();
		else div = gcd(x, y);
		return VT(x/div, y/div);
	}
	T dot(const VT& rhs) const { // 내적
		return x*rhs.x + y*rhs.y;
	}
	T cross(const VT& rhs) const { // 외적
		return x*rhs.y - y*rhs.x;
	}
	// 현재 벡터를 rhs에 사영한 벡터를 반환
	VT project(const VT& rhs) const {
		if constexpr(is_same_v<T, double>) {
			VT r = rhs.normalize();
			return r * r.dot(*this);
		}
		else {assert(0); return VT(0, 0);}
	}
};
template<typename T>
ostream& operator <<(ostream& os, const VT<T>& p) {
	os << p.x << ' ' << p.y; return os;
}
template<typename T>
istream& operator >>(istream& is, VT<T>& p) {
	is >> p.x >> p.y; return is;
}

template <typename T>
T ccw(VT<T> a, VT<T> b, VT<T> c) {
	return (b-a).cross(c-a);
}
// 점 p,a,b가 일직선상에 있을 때 p가 [a, b]에 있는지 본다
template <typename T>
bool inRange(VT<T> p, VT<T> a, VT<T> b) {
	if (b < a) swap(a, b);
	return a <= p && p <= b;
}

// ab를 포함하는 직선과 cd를 포함하는 직선의 교점을 구해 x에 저장
// 교점이 존재하면 참, 존재하지 않으면(평행/겹침) 거짓을 반환
template <typename T>
bool lineIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		double det = (b-a).cross(d-c);
		if (equal(det, (T)0)) return false;
		x = a + (b-a) * ((c-a).cross(d-c) / det);
		return true;
	}
	else {assert(0); return false;}
}

// ab선분과 cd선분이 겹치는지 여부를 반환
template <typename T>
bool segIntersect(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	T tmp1 = ccw(a, b, c), tmp2 = ccw(a, b, d);
	T tmp3 = ccw(c, d, a), tmp4 = ccw(c, d, b);
	T ab = 0, cd = 0;
	if constexpr(is_same_v<T, double>) {
		ab = tmp1*tmp2; cd = tmp3*tmp4;
	}
	else {
		if (tmp1 != 0 && tmp2 != 0) {
			tmp1 /= abs(tmp1); tmp2 /= abs(tmp2);
			ab = tmp1*tmp2;
		}
		if (tmp3 != 0 && tmp4 != 0) {
			tmp3 /= abs(tmp3); tmp4 /= abs(tmp4);
			cd = tmp3*tmp4;
		}
	}
	// 두 선분이 한 직선 위에 있거나 끝 점이 겹치는 경우
	if (equal(ab, (T)0) && equal(cd, (T)0)) {
		if (b < a) swap(a, b);
		if (d < c) swap(c, d);
		return !(d < a || b < c);
	}
	// 선분에 다른 선분이 접촉한 경우도 고려
	return (equal(ab, (T)0) || ab < 0) &&
		(equal(cd, (T)0) || cd < 0);
}

// ab선분과 cd선분이 겹치는지 여부를 반환
// 겹치는 경우 교점(무한개면 임의의 교점)을 x에 저장
template <typename T>
bool segIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		if (lineIntersection(a, b, c, d, x))
			return inRange(x, a, b) && inRange(x, c, d);
		if (b < a) swap(a, b); if (d < c) swap(c, d);
		if (!equal(ccw(a, b, c), (T)0) || d < a || b < c) return false;
		if (a < c) x = c; else x = a;
		return true;
	}
	else {assert(0); return false;}
}

// 점 p에서 ab직선에 내린 수선의 발을 반환
template <typename T>
VT<T> foot(VT<T> p, VT<T> a, VT<T> b) {
	return a + (p-a).project(b-a);
}

// 점 p에서 ab직선까지의 최소 거리를 반환
template <typename T>
T pointToLine(VT<T> p, VT<T> a, VT<T> b) {
	return (p-foot(p, a, b)).norm();
}

// 점 p에서 ab선분까지의 최소 거리를 반환
template <typename T>
T pointToSeg(VT<T> p, VT<T> a, VT<T> b) {
	VT h = foot(p, a, b);
	if (inRange(h, a, b)) return (p-h).norm();
	return min((p-a).norm(), (p-b).norm());
}

// ab선분에서 cd선분까지의 최소 거리를 반환
template <typename T>
T segToSeg(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	if (segIntersect(a, b, c, d)) return (T)0;
	return min({pointToSeg(a, c, d), pointToSeg(b, c, d),
		pointToSeg(c, a, b), pointToSeg(d, a, b)});
}

// 다각형 p의 넓이를 반환, 정수형의 경우 2로 나누지 않음
template <typename T>
T area(const vector<VT<T>>& p) {
	T ret = 0;
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		ret += p[i].cross(p[j]);
	}
	if constexpr(is_same_v<T, double>) return fabs(ret)/2;
	else return abs(ret);
}

// 점 q가 다각형 p의 경계에 위치하는지 여부를 반환
template <typename T>
bool onBound(const vector<VT<T>>& p, VT<T> q) {
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		if (equal(ccw(q, p[i], p[j]), (T)0) &&
			inRange(q, p[i], p[j]))
			return true;
	}
	return false;
}

// 점 q가 다각형 p의 내부에 있는지 외부에 있는지를 판별
template <typename T>
bool inside(const vector<VT<T>>& p, VT<T> q) {
	if constexpr(is_same_v<T, double>) {
		if (onBound(p, q)) return false;
		int cross = 0, n = sz(p);
		for (int i = 0; i < n; ++i) {
			int j = (i+1)%n;
			if ((!equal(p[i].y, q.y) && p[i].y > q.y) !=
				(!equal(p[j].y, q.y) && p[j].y > q.y)) {
				double atX = (q.y - p[i].y) * (p[j].x - p[i].x) /
					(p[j].y - p[i].y) + p[i].x;
				if (q.x < atX) ++cross;
			}
		}
		return cross%2 > 0;
	}
	else {assert(0); return false;}
}

bool isA(VT<int> from, VT<int> to1, VT<int> to2, VT<int> a, VT<int> b) {
	// 1. from-to1, from-to2의 각도
	if ((to1-from).cross(to2-from) == 0) return false;
	if ((to1-from).dot(to2-from) < 0) return false;

	// 2. ab선분은 from-to1, from-to2에 걸침
	int cval1 = ccw(from, to1, a), cval2 = ccw(from, to1, b);
	if (cval1 != 0 && cval2 != 0) return false;
	if (cval2 == 0) swap(a, b);
	if (ccw(from, to2, b) != 0) return false;

	if (!inRange(a, from, to1)) return false;
	assert(segIntersect(from, to1, a, b));
	int dist1 = (a-from).norm(), dist2 = (a-to1).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;

	if (!inRange(b, from, to2)) return false;
	assert(segIntersect(from, to2, a, b));
	dist1 = (b-from).norm(); dist2 = (b-to2).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;
	return true;
}

void solve(int tc) {
	VT<int> p[3][2];
	for (int i = 0; i < 3; ++i) {
		cin >> p[i][0] >> p[i][1];
	}
	bool valid = false;
	for (int i = 0; i < 3; ++i)
		for (int j = i+1; j < 3; ++j) {
			int k = 3-i-j;
			for (int x = 0; x < 2; ++x)
				for (int y = 0; y < 2; ++y)
					if (p[i][x] == p[j][y]) {
						valid |= isA(p[i][x], p[i][1-x], p[j][1-y], p[k][0], p[k][1]);
					}
		}
	cout << (valid ? "YES" : "NO") << '\n';
}

/***********************************************************************************/
signed main(signed argc, char *argv[]) {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(11);
	bool mult = (MULTITEST && !(argc == 2 && (string)argv[1] == "test"));
	int T = 1; if (mult) cin >> T;
	for (int tc = 1; tc <= T; ++tc) solve(tc);
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pushf push_front
#define popf pop_front
#define pushb push_back
#define popb pop_back
// caution: MLE → comment below and use explicit "ll"
#define int ll

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pii>;
using vll = vector<pll>;
template <typename T> using pqmax = priority_queue<T>;
template <typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;

template <typename T> T inf() {return numeric_limits<T>::max()/2;}
template <typename T> inline T sq(T x){return x*x;}
template<typename A, typename B>
ostream& operator <<(ostream& os, const pair<A, B>& x) {
	os << x.fst << ' ' << x.snd; return os;
}
template<typename A, typename B>
istream& operator >>(istream& is, pair<A, B>& x) {
	is >> x.fst >> x.snd; return is;
}
template<typename A, typename B>
pair<A, B> operator +(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst+b.fst, a.snd+b.snd);
}
template<typename A, typename B>
pair<A, B> operator -(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst-b.fst, a.snd-b.snd);
}
template <typename T> auto cinvec(int n, int base=0) {
	vector<T> v(n+base);
	for (int i = base; i < sz(v); ++i) cin >> v[i];
	return v;
}
template <typename T> void memset(T& x, int val) {
	memset(x, val, sizeof(x));
}
template <typename T> void sort(T& x, int base=0) {
	sort(x.begin()+base, x.end());
}
template <typename T> void reverse(T& x, int base=0) {
	reverse(x.begin()+base, x.end());
}
template <typename T> void uniq(T& x, int base=0) {
	x.erase(unique(x.begin()+base, x.end()), x.end());
}
template <typename T> int lbpos(T& x, int val, int base=0) {
	return lower_bound(x.begin()+base, x.end(), val) - x.begin();
}
template <typename T> ll getsum(vector<T>& x, int base=0) {
	ll ret = 0;
	for (int i = base; i < sz(x); ++i) ret += x[i];
	return ret;
}
template <typename T> T getmax(vector<T>& x, int base=0) {
	return *max_element(x.begin()+base, x.end());
}
template <typename T> T getmin(vector<T>& x, int base=0) {
	return *min_element(x.begin()+base, x.end());
}
ll rand(ll mn, ll mx=LLONG_MAX/2){
	static mt19937 rng(time(0)^ll(new int));
	return uniform_int_distribution<ll>(mn, mx-1)(rng);
}

/***********************************************************************************/
#define MULTITEST 1
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
const ll MOD = 998244353;
const ll MAX = 3002;

/***********************************************************************************/
const double PI = 2*acos(0.0);
template <typename T>
bool equal(T a, T b) {
	if constexpr(is_same_v<T, double>) {
		double diff = fabs(a-b);
		if (diff < 1e-10) return true;
		return diff < 1e-8 * max(fabs(a), fabs(b));
	}
	return a==b;
}

template <typename T>
struct VT {
	T x, y;
	VT(T _x=0, T _y=0) : x(_x),y(_y){}
	bool operator ==(const VT& rhs) const {
		return equal(x, rhs.x) && equal(y, rhs.y);
	}
	bool operator <(const VT& rhs) const {
		if (*this == rhs) return false;
		return !equal(x, rhs.x) ? x < rhs.x : y < rhs.y;
	}
	bool operator <=(const VT& rhs) const {
		return *this == rhs || *this < rhs;
	}
	VT operator +(const VT& rhs) const {
		return VT(x+rhs.x, y+rhs.y);
	}
	VT operator -(const VT& rhs) const {
		return VT(x-rhs.x, y-rhs.y);
	}
	VT operator -() const {
		return VT(-x, -y);
	}
	VT operator *(T rhs) const {
		return VT(x*rhs, y*rhs);
	}
	T norm() const { // 벡터의 크기 반환, 정수형의 경우 크기 제곱
		if constexpr(is_same_v<T, double>) return hypot(x, y);
		return sq(x)+sq(y);
	}
	VT normalize() const { // 현재 벡터의 방향을 갖는 단위벡터 반환
		if (equal(norm(), (T)0)) return *this;
		T div = 0;
		if constexpr(is_same_v<T, double>) div = norm();
		else div = gcd(x, y);
		return VT(x/div, y/div);
	}
	T dot(const VT& rhs) const { // 내적
		return x*rhs.x + y*rhs.y;
	}
	T cross(const VT& rhs) const { // 외적
		return x*rhs.y - y*rhs.x;
	}
	// 현재 벡터를 rhs에 사영한 벡터를 반환
	VT project(const VT& rhs) const {
		if constexpr(is_same_v<T, double>) {
			VT r = rhs.normalize();
			return r * r.dot(*this);
		}
		else {assert(0); return VT(0, 0);}
	}
};
template<typename T>
ostream& operator <<(ostream& os, const VT<T>& p) {
	os << p.x << ' ' << p.y; return os;
}
template<typename T>
istream& operator >>(istream& is, VT<T>& p) {
	is >> p.x >> p.y; return is;
}

template <typename T>
T ccw(VT<T> a, VT<T> b, VT<T> c) {
	return (b-a).cross(c-a);
}
// 점 p,a,b가 일직선상에 있을 때 p가 [a, b]에 있는지 본다
template <typename T>
bool inRange(VT<T> p, VT<T> a, VT<T> b) {
	if (b < a) swap(a, b);
	return a <= p && p <= b;
}

// ab를 포함하는 직선과 cd를 포함하는 직선의 교점을 구해 x에 저장
// 교점이 존재하면 참, 존재하지 않으면(평행/겹침) 거짓을 반환
template <typename T>
bool lineIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		double det = (b-a).cross(d-c);
		if (equal(det, (T)0)) return false;
		x = a + (b-a) * ((c-a).cross(d-c) / det);
		return true;
	}
	else {assert(0); return false;}
}

// ab선분과 cd선분이 겹치는지 여부를 반환 (오버플로우 주의)
template <typename T>
bool segIntersect(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	T tmp1 = ccw(a, b, c), tmp2 = ccw(a, b, d);
	T tmp3 = ccw(c, d, a), tmp4 = ccw(c, d, b);
	T ab = 0, cd = 0;
	if constexpr(is_same_v<T, double>) {
		ab = tmp1*tmp2; cd = tmp3*tmp4;
	}
	else {
		if (tmp1 != 0 && tmp2 != 0) {
			tmp1 /= abs(tmp1); tmp2 /= abs(tmp2);
			ab = tmp1*tmp2;
		}
		if (tmp3 != 0 && tmp4 != 0) {
			tmp3 /= abs(tmp3); tmp4 /= abs(tmp4);
			cd = tmp3*tmp4;
		}
	}
	// 두 선분이 한 직선 위에 있거나 끝 점이 겹치는 경우
	if (equal(ab, (T)0) && equal(cd, (T)0)) {
		if (b < a) swap(a, b);
		if (d < c) swap(c, d);
		return !(d < a || b < c);
	}
	// 선분에 다른 선분이 접촉한 경우도 고려
	return (equal(ab, (T)0) || ab < 0) &&
		(equal(cd, (T)0) || cd < 0);
}

// ab선분과 cd선분이 겹치는지 여부를 반환
// 겹치는 경우 교점(무한개면 임의의 교점)을 x에 저장
template <typename T>
bool segIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		if (lineIntersection(a, b, c, d, x))
			return inRange(x, a, b) && inRange(x, c, d);
		if (b < a) swap(a, b); if (d < c) swap(c, d);
		if (!equal(ccw(a, b, c), (T)0) || d < a || b < c) return false;
		if (a < c) x = c; else x = a;
		return true;
	}
	else {assert(0); return false;}
}

// 점 p에서 ab직선에 내린 수선의 발을 반환
template <typename T>
VT<T> foot(VT<T> p, VT<T> a, VT<T> b) {
	return a + (p-a).project(b-a);
}

// 점 p에서 ab직선까지의 최소 거리를 반환
template <typename T>
T pointToLine(VT<T> p, VT<T> a, VT<T> b) {
	return (p-foot(p, a, b)).norm();
}

// 점 p에서 ab선분까지의 최소 거리를 반환
template <typename T>
T pointToSeg(VT<T> p, VT<T> a, VT<T> b) {
	VT h = foot(p, a, b);
	if (inRange(h, a, b)) return (p-h).norm();
	return min((p-a).norm(), (p-b).norm());
}

// ab선분에서 cd선분까지의 최소 거리를 반환
template <typename T>
T segToSeg(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	if (segIntersect(a, b, c, d)) return (T)0;
	return min({pointToSeg(a, c, d), pointToSeg(b, c, d),
		pointToSeg(c, a, b), pointToSeg(d, a, b)});
}

// 다각형 p의 넓이를 반환, 정수형의 경우 2로 나누지 않음
template <typename T>
T area(const vector<VT<T>>& p) {
	T ret = 0;
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		ret += p[i].cross(p[j]);
	}
	if constexpr(is_same_v<T, double>) return fabs(ret)/2;
	else return abs(ret);
}

// 점 q가 다각형 p의 경계에 위치하는지 여부를 반환
template <typename T>
bool onBound(const vector<VT<T>>& p, VT<T> q) {
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		if (equal(ccw(q, p[i], p[j]), (T)0) &&
			inRange(q, p[i], p[j]))
			return true;
	}
	return false;
}

// 점 q가 다각형 p의 내부에 있는지 외부에 있는지를 판별
template <typename T>
bool inside(const vector<VT<T>>& p, VT<T> q) {
	if constexpr(is_same_v<T, double>) {
		if (onBound(p, q)) return false;
		int cross = 0, n = sz(p);
		for (int i = 0; i < n; ++i) {
			int j = (i+1)%n;
			if ((!equal(p[i].y, q.y) && p[i].y > q.y) !=
				(!equal(p[j].y, q.y) && p[j].y > q.y)) {
				double atX = (q.y - p[i].y) * (p[j].x - p[i].x) /
					(p[j].y - p[i].y) + p[i].x;
				if (q.x < atX) ++cross;
			}
		}
		return cross%2 > 0;
	}
	else {assert(0); return false;}
}

bool isA(VT<int> from, VT<int> to1, VT<int> to2, VT<int> a, VT<int> b) {
	// 1. from-to1, from-to2의 각도
	if ((to1-from).cross(to2-from) == 0) return false;
	if ((to1-from).dot(to2-from) < 0) return false;

	// 2. ab선분은 from-to1, from-to2에 걸침
	int cval1 = ccw(from, to1, a), cval2 = ccw(from, to1, b);
	if (cval1 != 0 && cval2 != 0) return false;
	if (cval2 == 0) swap(a, b);

	if (!inRange(a, from, to1)) return false;
	assert(segIntersect(from, to1, a, b));
	int dist1 = (a-from).norm(), dist2 = (a-to1).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;

	if (!inRange(b, from, to2)) return false;
	assert(segIntersect(from, to2, a, b));
	dist1 = (b-from).norm(); dist2 = (b-to2).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;
	return true;
}

void solve(int tc) {
	VT<int> p[3][2];
	for (int i = 0; i < 3; ++i) {
		cin >> p[i][0] >> p[i][1];
	}
	bool valid = false;
	for (int i = 0; i < 3; ++i)
		for (int j = i+1; j < 3; ++j) {
			int k = 3-i-j;
			for (int x = 0; x < 2; ++x)
				for (int y = 0; y < 2; ++y)
					if (p[i][x] == p[j][y]) {
						valid |= isA(p[i][x], p[i][1-x], p[j][1-y], p[k][0], p[k][1]);
					}
		}
	cout << (valid ? "YES" : "NO") << '\n';
}

/***********************************************************************************/
signed main(signed argc, char *argv[]) {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(11);
	bool mult = (MULTITEST && !(argc == 2 && (string)argv[1] == "test"));
	int T = 1; if (mult) cin >> T;
	for (int tc = 1; tc <= T; ++tc) solve(tc);
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pushf push_front
#define popf pop_front
#define pushb push_back
#define popb pop_back
// caution: MLE → comment below and use explicit "ll"
#define int ll

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pii>;
using vll = vector<pll>;
template <typename T> using pqmax = priority_queue<T>;
template <typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;

template <typename T> T inf() {return numeric_limits<T>::max()/2;}
template <typename T> inline T sq(T x){return x*x;}
template<typename A, typename B>
ostream& operator <<(ostream& os, const pair<A, B>& x) {
	os << x.fst << ' ' << x.snd; return os;
}
template<typename A, typename B>
istream& operator >>(istream& is, pair<A, B>& x) {
	is >> x.fst >> x.snd; return is;
}
template<typename A, typename B>
pair<A, B> operator +(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst+b.fst, a.snd+b.snd);
}
template<typename A, typename B>
pair<A, B> operator -(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst-b.fst, a.snd-b.snd);
}
template <typename T> auto cinvec(int n, int base=0) {
	vector<T> v(n+base);
	for (int i = base; i < sz(v); ++i) cin >> v[i];
	return v;
}
template <typename T> void memset(T& x, int val) {
	memset(x, val, sizeof(x));
}
template <typename T> void sort(T& x, int base=0) {
	sort(x.begin()+base, x.end());
}
template <typename T> void reverse(T& x, int base=0) {
	reverse(x.begin()+base, x.end());
}
template <typename T> void uniq(T& x, int base=0) {
	x.erase(unique(x.begin()+base, x.end()), x.end());
}
template <typename T> int lbpos(T& x, int val, int base=0) {
	return lower_bound(x.begin()+base, x.end(), val) - x.begin();
}
template <typename T> ll getsum(vector<T>& x, int base=0) {
	ll ret = 0;
	for (int i = base; i < sz(x); ++i) ret += x[i];
	return ret;
}
template <typename T> T getmax(vector<T>& x, int base=0) {
	return *max_element(x.begin()+base, x.end());
}
template <typename T> T getmin(vector<T>& x, int base=0) {
	return *min_element(x.begin()+base, x.end());
}
ll rand(ll mn, ll mx=LLONG_MAX/2){
	static mt19937 rng(time(0)^ll(new int));
	return uniform_int_distribution<ll>(mn, mx-1)(rng);
}

/***********************************************************************************/
#define MULTITEST 1
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
const ll MOD = 998244353;
const ll MAX = 3002;

/***********************************************************************************/
const double PI = 2*acos(0.0);
template <typename T>
bool equal(T a, T b) {
	if constexpr(is_same_v<T, double>) {
		double diff = fabs(a-b);
		if (diff < 1e-10) return true;
		return diff < 1e-8 * max(fabs(a), fabs(b));
	}
	return a==b;
}

template <typename T>
struct VT {
	T x, y, id;
	VT(T _x=0, T _y=0) : x(_x),y(_y){}
	bool operator ==(const VT& rhs) const {
		return equal(x, rhs.x) && equal(y, rhs.y);
	}
	bool operator <(const VT& rhs) const {
		if (*this == rhs) return false;
		return !equal(x, rhs.x) ? x < rhs.x : y < rhs.y;
	}
	bool operator <=(const VT& rhs) const {
		return *this == rhs || *this < rhs;
	}
	VT operator +(const VT& rhs) const {
		return VT(x+rhs.x, y+rhs.y);
	}
	VT operator -(const VT& rhs) const {
		return VT(x-rhs.x, y-rhs.y);
	}
	VT operator -() const {
		return VT(-x, -y);
	}
	VT operator *(T rhs) const {
		return VT(x*rhs, y*rhs);
	}
	T norm() const { // 벡터의 크기 반환, 정수형의 경우 크기 제곱
		if constexpr(is_same_v<T, double>) return hypot(x, y);
		return sq(x)+sq(y);
	}
	VT normalize() const { // 현재 벡터의 방향을 갖는 단위벡터 반환
		if (equal(norm(), (T)0)) return *this;
		T div = 0;
		if constexpr(is_same_v<T, double>) div = norm();
		else div = gcd(x, y);
		return VT(x/div, y/div);
	}
	T dot(const VT& rhs) const { // 내적
		return x*rhs.x + y*rhs.y;
	}
	T cross(const VT& rhs) const { // 외적
		return x*rhs.y - y*rhs.x;
	}
	// 현재 벡터를 rhs에 사영한 벡터를 반환
	VT project(const VT& rhs) const {
		if constexpr(is_same_v<T, double>) {
			VT r = rhs.normalize();
			return r * r.dot(*this);
		}
		else {assert(0); return VT(0, 0);}
	}
};
template<typename T>
ostream& operator <<(ostream& os, const VT<T>& p) {
	os << p.x << ' ' << p.y; return os;
}
template<typename T>
istream& operator >>(istream& is, VT<T>& p) {
	is >> p.x >> p.y; return is;
}

template <typename T>
T ccw(VT<T> a, VT<T> b, VT<T> c) {
	return (b-a).cross(c-a);
}
// 점 p,a,b가 일직선상에 있을 때 p가 [a, b]에 있는지 본다
template <typename T>
bool inRange(VT<T> p, VT<T> a, VT<T> b) {
	if (b < a) swap(a, b);
	return a <= p && p <= b;
}

// ab를 포함하는 직선과 cd를 포함하는 직선의 교점을 구해 x에 저장
// 교점이 존재하면 참, 존재하지 않으면(평행/겹침) 거짓을 반환
template <typename T>
bool lineIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		double det = (b-a).cross(d-c);
		if (equal(det, (T)0)) return false;
		x = a + (b-a) * ((c-a).cross(d-c) / det);
		return true;
	}
	else {assert(0); return false;}
}

// ab선분과 cd선분이 겹치는지 여부를 반환 (오버플로우 주의)
template <typename T>
bool segIntersect(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	T tmp1 = ccw(a, b, c), tmp2 = ccw(a, b, d);
	T tmp3 = ccw(c, d, a), tmp4 = ccw(c, d, b);
	T ab = 0, cd = 0;
	if constexpr(is_same_v<T, double>) {
		ab = tmp1*tmp2; cd = tmp3*tmp4;
	}
	else {
		if (tmp1 != 0 && tmp2 != 0) {
			tmp1 /= abs(tmp1); tmp2 /= abs(tmp2);
			ab = tmp1*tmp2;
		}
		if (tmp3 != 0 && tmp4 != 0) {
			tmp3 /= abs(tmp3); tmp4 /= abs(tmp4);
			cd = tmp3*tmp4;
		}
	}
	// 두 선분이 한 직선 위에 있거나 끝 점이 겹치는 경우
	if (equal(ab, (T)0) && equal(cd, (T)0)) {
		if (b < a) swap(a, b);
		if (d < c) swap(c, d);
		return !(d < a || b < c);
	}
	// 선분에 다른 선분이 접촉한 경우도 고려
	return (equal(ab, (T)0) || ab < 0) &&
		(equal(cd, (T)0) || cd < 0);
}

// ab선분과 cd선분이 겹치는지 여부를 반환
// 겹치는 경우 교점(무한개면 임의의 교점)을 x에 저장
template <typename T>
bool segIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		if (lineIntersection(a, b, c, d, x))
			return inRange(x, a, b) && inRange(x, c, d);
		if (b < a) swap(a, b); if (d < c) swap(c, d);
		if (!equal(ccw(a, b, c), (T)0) || d < a || b < c) return false;
		if (a < c) x = c; else x = a;
		return true;
	}
	else {assert(0); return false;}
}

// 점 p에서 ab직선에 내린 수선의 발을 반환
template <typename T>
VT<T> foot(VT<T> p, VT<T> a, VT<T> b) {
	return a + (p-a).project(b-a);
}

// 점 p에서 ab직선까지의 최소 거리를 반환
template <typename T>
T pointToLine(VT<T> p, VT<T> a, VT<T> b) {
	return (p-foot(p, a, b)).norm();
}

// 점 p에서 ab선분까지의 최소 거리를 반환
template <typename T>
T pointToSeg(VT<T> p, VT<T> a, VT<T> b) {
	VT h = foot(p, a, b);
	if (inRange(h, a, b)) return (p-h).norm();
	return min((p-a).norm(), (p-b).norm());
}

// ab선분에서 cd선분까지의 최소 거리를 반환
template <typename T>
T segToSeg(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	if (segIntersect(a, b, c, d)) return (T)0;
	return min({pointToSeg(a, c, d), pointToSeg(b, c, d),
		pointToSeg(c, a, b), pointToSeg(d, a, b)});
}

// 다각형 p의 넓이를 반환, 정수형의 경우 2로 나누지 않음
template <typename T>
T area(const vector<VT<T>>& p) {
	T ret = 0;
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		ret += p[i].cross(p[j]);
	}
	if constexpr(is_same_v<T, double>) return fabs(ret)/2;
	else return abs(ret);
}

// 점 q가 다각형 p의 경계에 위치하는지 여부를 반환
template <typename T>
bool onBound(const vector<VT<T>>& p, VT<T> q) {
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		if (equal(ccw(q, p[i], p[j]), (T)0) &&
			inRange(q, p[i], p[j]))
			return true;
	}
	return false;
}

// 점 q가 다각형 p의 내부에 있는지 외부에 있는지를 판별
template <typename T>
bool inside(const vector<VT<T>>& p, VT<T> q) {
	if constexpr(is_same_v<T, double>) {
		if (onBound(p, q)) return false;
		int cross = 0, n = sz(p);
		for (int i = 0; i < n; ++i) {
			int j = (i+1)%n;
			if ((!equal(p[i].y, q.y) && p[i].y > q.y) !=
				(!equal(p[j].y, q.y) && p[j].y > q.y)) {
				double atX = (q.y - p[i].y) * (p[j].x - p[i].x) /
					(p[j].y - p[i].y) + p[i].x;
				if (q.x < atX) ++cross;
			}
		}
		return cross%2 > 0;
	}
	else {assert(0); return false;}
}

bool isA(VT<int> from, VT<int> to1, VT<int> to2, VT<int> a, VT<int> b) {
	// 1. from-to1, from-to2의 각도
	if ((to1-from).cross(to2-from) == 0) return false;
	if (to1-from.dot(to2-from) < 0) return false;

	// 2. from-to 와 a-b의 교차점
	for (auto to : {to1, to2}) {
		// 선분이 삐죽 튀어나와도 안되네 문제 설명 실환가
		if (ccw(from, to, a) && ccw(from, to, b)) return false;
		if (!segIntersect(from, to, a, b)) return false;

		// 교차점이 정확히 from-to의 p:q 내분지점에 있는 경우
		bool bound = false;
		for (auto p : {1, 4}) {
			int q = 5-p;
			int crossX = p*to.x + q*from.x;
			int crossY = p*to.y + q*from.y;
			if (crossX%5 || crossY%5) continue;
			crossX /= 5; crossY /= 5;
			if (ccw(a, b, VT<int>(crossX, crossY)) == 0) {
				bound = true; break;
			}
		}
		if (bound) continue;

		VT<double> dfrom(from.x, from.y);
		VT<double> dto(to.x, to.y);
		VT<double> da(a.x, a.y), db(b.x, b.y);
		VT<double> cross;

		assert(segIntersection(dfrom, dto, da, db, cross));
		double dist1 = (dfrom-cross).norm();
		double dist2 = (dto-cross).norm();
		if (equal(dist1, 0.0) || equal(dist2, 0.0)) return false;
		if (dist1 > dist2) swap(dist1, dist2);
		double ratio = dist1/dist2;
		if (ratio < 0.25) return false;
	}
	return true;
}

void solve(int tc) {
	VT<int> p[3][2];
	for (int i = 0; i < 3; ++i) {
		cin >> p[i][0] >> p[i][1];
	}
	bool valid = false;
	for (int i = 0; i < 3; ++i)
		for (int j = i+1; j < 3; ++j) {
			int k = 3-i-j;
			for (int x = 0; x < 2; ++x)
				for (int y = 0; y < 2; ++y)
					if (p[i][x] == p[j][y]) {
						valid |= isA(p[i][x], p[i][1-x], p[j][1-y], p[k][0], p[k][1]);
					}
		}
	cout << (valid ? "YES" : "NO") << '\n';
}

/***********************************************************************************/
signed main(signed argc, char *argv[]) {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(11);
	bool mult = (MULTITEST && !(argc == 2 && (string)argv[1] == "test"));
	int T = 1; if (mult) cin >> T;
	for (int tc = 1; tc <= T; ++tc) solve(tc);
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-12;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1<<30,-1<<30);
	}
	if(x1[i]==x2[i]){
		if(fabs(x1[j]-x1[i])<=eps){
			if(y1[j]<min(y1[i],y2[i])||y1[j]>max(y1[i],y2[i])) return mp(-1<<30,-1<<30);
			return mp(x1[i],y1[j]);
		}
		else if(fabs(x2[j]-x1[i])<=eps){
			if(y2[j]<min(y1[i],y2[i])||y2[j]>max(y1[i],y2[i])) return mp(-1<<30,-1<<30);
			return mp(x1[i],y2[j]);
		}
		else return mp(-1<<30,-1<<30);
	}
	if(x1[j]==x2[j]){
		if(fabs(x1[i]-x1[j])<=eps){
			if(y1[i]<min(y1[j],y2[j])||y1[i]>max(y1[j],y2[j])) return mp(-1<<30,-1<<30);
			return mp(x1[j],y1[i]);
		}
		else if(fabs(x2[i]-x1[j])<=eps){
			if(y2[i]<min(y1[j],y2[j])||y2[i]>max(y1[j],y2[j])) return mp(-1<<30,-1<<30);
			return mp(x1[j],y2[i]);
		}
		else return mp(-1<<30,-1<<30);
	}
	ld k1=(y2[i]-y1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i]);
//	cout<<"test "<<i<<' '<<j<<' '<<k1<<' '<<b1<<endl;
	if(fabs(k1*x1[j]+b1-y1[j]*(x2[i]-x1[i]))>eps&&fabs(k1*x2[j]+b1-y2[j]*(x2[i]-x1[i]))>eps) return mp(-1<<30,-1<<30);
	if(fabs(k1*x1[j]+b1-y1[j]*(x2[i]-x1[i]))<=eps){
		return mp(x1[j],y1[j]);
	}
	else{
		return mp(x2[j],y2[j]);
	}
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<-eps) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
//	cout<<"p "<<p1.fi<<' '<<p1.se<<' '<<p2.fi<<' '<<p2.se<<endl;
	if(p1.fi==(-1<<30)||p2.fi==(-1<<30)) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		for(int i=1;i<=3;i++) if(x1[i]>x2[i]) swap(x1[i],x2[i]),swap(y1[i],y2[i]);
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-12;
int n;
ll x1[5],x2[5],y1[5],y2[5];

ll dist(pll x,pll y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pll getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1<<30,-1<<30);
	}
	if(x1[i]==x2[i]){
		if(x1[j]==x1[i]){
			if(y1[j]<min(y1[i],y2[i])||y1[j]>max(y1[i],y2[i])) return mp(-1<<30,-1<<30);
			return mp(x1[i],y1[j]);
		}
		else if(x2[j]==x1[i]){
			if(y2[j]<min(y1[i],y2[i])||y2[j]>max(y1[i],y2[i])) return mp(-1<<30,-1<<30);
			return mp(x1[i],y2[j]);
		}
		else return mp(-1<<30,-1<<30);
	}
	if(x1[j]==x2[j]){
		if(x1[i]==x1[j]){
			if(y1[i]<min(y1[j],y2[j])||y1[i]>max(y1[j],y2[j])) return mp(-1<<30,-1<<30);
			return mp(x1[j],y1[i]);
		}
		else if(x2[i]==x1[j]){
			if(y2[i]<min(y1[j],y2[j])||y2[i]>max(y1[j],y2[j])) return mp(-1<<30,-1<<30);
			return mp(x1[j],y2[i]);
		}
		else return mp(-1<<30,-1<<30);
	}
	ld k1=(y2[i]-y1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i]);
//	cout<<"test "<<i<<' '<<j<<' '<<k1<<' '<<b1<<endl;
	if(k1*x1[j]+b1!=y1[j]*(x2[i]-x1[i])&&k1*x2[j]+b1!=y2[j]*(x2[i]-x1[i])) return mp(-1<<30,-1<<30);
	if(k1*x1[j]+b1==y1[j]*(x2[i]-x1[i])){
		return mp(x1[j],y1[j]);
	}
	else{
		return mp(x2[j],y2[j]);
	}
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<0) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
//	cout<<"p "<<p1.fi<<' '<<p1.se<<' '<<p2.fi<<' '<<p2.se<<endl;
	if(p1.fi==(-1<<30)||p2.fi==(-1<<30)) return false;
	ll dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		for(int i=1;i<=3;i++) if(x1[i]>x2[i]) swap(x1[i],x2[i]),swap(y1[i],y2[i]);
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-9;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1,-1);
	}
	if(x1[j]==x2[j]){
		if(fabs(x1[j]-x1[i])>eps&&fabs(x1[j]-x2[i])>eps) return mp(-1,-1);
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			ld tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])-eps||tmp>max(y1[j],y2[j])+eps) return mp(-1,-1);
			return mp(x1[j],tmp);
		}
		else return mp(-1,-1);
	}
	if(x1[i]==x2[i]){
		if(fabs(x1[i]-x1[j])>eps&&fabs(x1[i]-x2[j])>eps) return mp(-1,-1);
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			ld tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])-eps||tmp>max(y1[i],y2[i])+eps) return mp(-1,-1);
			return mp(x1[i],tmp);
		}
		else return mp(-1,-1);
	}
	ld k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	ld k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	if(k1==k2) return mp(-1,-1);
	ld tmpx=(b2-b1)/(k1-k2);
	if(fabs(tmpx-x1[j])>eps&&fabs(tmpx-x2[j])>eps) return mp(-1,-1);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1,-1);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1,-1);
	ld tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1,-1);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1,-1);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<-eps) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi<0||p2.fi<0) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(min(dis1,dis2)/max(dis1,dis2)<(ld)1/16-eps) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(min(dis1,dis2)/max(dis1,dis2)<(ld)1/16-eps) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-9;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1<<30,-1<<30);
	}
	if(x1[j]==x2[j]){
		if(fabs(x1[j]-x1[i])>eps&&fabs(x1[j]-x2[i])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			ld tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])-eps||tmp>max(y1[j],y2[j])+eps) return mp(-1<<30,-1<<30);
			return mp(x1[j],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	if(x1[i]==x2[i]){
		if(fabs(x1[i]-x1[j])>eps&&fabs(x1[i]-x2[j])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			ld tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])-eps||tmp>max(y1[i],y2[i])+eps) return mp(-1<<30,-1<<30);
			return mp(x1[i],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	ld k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	ld k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	if(k1==k2) return mp(-1,-1);
	ld tmpx=(b2-b1)/(k1-k2);
	if(fabs(tmpx-x1[j])>eps&&fabs(tmpx-x2[j])>eps) return mp(-1<<30,-1<<30);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1<<30,-1<<30);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1<<30,-1<<30);
	ld tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1<<30,-1<<30);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1<<30,-1<<30);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<-eps) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi==(-1<<30)||p2.fi==(-1<<30)) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-15;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1<<30,-1<<30);
	}
	if(x1[j]==x2[j]){
		if(fabs(x1[j]-x1[i])>eps&&fabs(x1[j]-x2[i])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			ld tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])-eps||tmp>max(y1[j],y2[j])+eps) return mp(-1<<30,-1<<30);
			return mp(x1[j],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	if(x1[i]==x2[i]){
		if(fabs(x1[i]-x1[j])>eps&&fabs(x1[i]-x2[j])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			ld tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])-eps||tmp>max(y1[i],y2[i])+eps) return mp(-1<<30,-1<<30);
			return mp(x1[i],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	ld k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	ld k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	if(k1==k2) return mp(-1,-1);
	ld tmpx=(b2-b1)/(k1-k2);
	if(fabs(tmpx-x1[j])>eps&&fabs(tmpx-x2[j])>eps) return mp(-1<<30,-1<<30);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1<<30,-1<<30);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1<<30,-1<<30);
	ld tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1<<30,-1<<30);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1<<30,-1<<30);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<-eps) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi==(-1<<30)||p2.fi==(-1<<30)) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-12;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1<<30,-1<<30);
	}
	if(x1[j]==x2[j]){
		if(fabs(x1[j]-x1[i])>eps&&fabs(x1[j]-x2[i])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			ld tmp=(y2[i]-y1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i]);
			if(tmp<min(y1[j],y2[j])*(x2[i]-x1[i])||tmp>max(y1[j],y2[j])*(x2[i]-x1[i])) return mp(-1<<30,-1<<30);
			return mp(x1[j],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	if(x1[i]==x2[i]){
		if(fabs(x1[i]-x1[j])>eps&&fabs(x1[i]-x2[j])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			ld tmp=(y2[j]-y1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j]);
			if(tmp<min(y1[i],y2[i])*(x2[j]-x1[j])||tmp>max(y1[i],y2[i])*(x2[j]-x1[j])) return mp(-1<<30,-1<<30);
			return mp(x1[i],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	ld k1=(y2[i]-y1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i]);
	if(fabs(k1*x1[j]+b1-y1[j]*(x2[i]-x1[i]))>eps&&fabs(k1*x2[j]+b1-y2[j]*(x2[i]-x1[i]))>eps) return mp(-1<<30,-1<<30);
	if(fabs(k1*x1[j]+b1-y1[j]*(x2[i]-x1[i]))<=eps){
		return mp(x1[j],x1[j]*k1+b1);
	}
	else{
		return mp(x2[j],x2[j]*k1+b1);
	}
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<-eps) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi==(-1<<30)||p2.fi==(-1<<30)) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		for(int i=1;i<=3;i++) if(x1[i]>x2[i]) swap(x1[i],x2[i]),swap(y1[i],y2[i]);
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<double,double> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-9;
int n;
double x1[5],x2[5],y1[5],y2[5];

double dist(pdd x,pdd y){return sqrt((x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se));}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1,-1);
	}
	if(x1[j]==x2[j]){
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			double tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])||tmp>max(y1[j],y2[j])) return mp(-1,-1);
			return mp(x1[j],tmp);
		}
		else return mp(-1,-1);
	}
	if(x1[i]==x2[i]){
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			double tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])||tmp>max(y1[i],y2[i])) return mp(-1,-1);
			return mp(x1[i],tmp);
		}
		else return mp(-1,-1);
	}
	double k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	double k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	double tmpx=(b2-b1)/(k1-k2);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1,-1);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1,-1);
	double tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1,-1);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1,-1);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<0) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi<0||p2.fi<0) return false;
	double dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(min(dis1,dis2)/max(dis1,dis2)<0.25) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(min(dis1,dis2)/max(dis1,dis2)<0.25) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)){
						fl=1;
					}
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-9;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return sqrt((x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se));}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1,-1);
	}
	if(x1[j]==x2[j]){
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			ld tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])-eps||tmp>max(y1[j],y2[j])+eps) return mp(-1,-1);
			return mp(x1[j],tmp);
		}
		else return mp(-1,-1);
	}
	if(x1[i]==x2[i]){
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			ld tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])-eps||tmp>max(y1[i],y2[i])+eps) return mp(-1,-1);
			return mp(x1[i],tmp);
		}
		else return mp(-1,-1);
	}
	ld k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	ld k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	if(k1==k2) return mp(-1,-1);
	ld tmpx=(b2-b1)/(k1-k2);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1,-1);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1,-1);
	ld tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1,-1);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1,-1);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<0) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi<0||p2.fi<0) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(min(dis1,dis2)/max(dis1,dis2)<0.25-eps) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(min(dis1,dis2)/max(dis1,dis2)<0.25-eps) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-12;
int n;
ll x1[5],x2[5],y1[5],y2[5];

ll dist(pll x,pll y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pll getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(1<<30,1<<30);
	}
	if(x1[i]==x2[i]){
		if(x1[j]==x1[i]){
			if(y1[j]<min(y1[i],y2[i])||y1[j]>max(y1[i],y2[i])) return mp(1<<30,1<<30);
			return mp(x1[i],y1[j]);
		}
		else if(x2[j]==x1[i]){
			if(y2[j]<min(y1[i],y2[i])||y2[j]>max(y1[i],y2[i])) return mp(1<<30,1<<30);
			return mp(x1[i],y2[j]);
		}
		else return mp(1<<30,1<<30);
	}
	if(x1[j]==x2[j]){
		if(x1[i]==x1[j]){
			if(y1[i]<min(y1[j],y2[j])||y1[i]>max(y1[j],y2[j])) return mp(1<<30,1<<30);
			return mp(x1[j],y1[i]);
		}
		else if(x2[i]==x1[j]){
			if(y2[i]<min(y1[j],y2[j])||y2[i]>max(y1[j],y2[j])) return mp(1<<30,1<<30);
			return mp(x1[j],y2[i]);
		}
		else return mp(1<<30,1<<30);
	}
	ld k1=(y2[i]-y1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i]);
//	cout<<"test "<<i<<' '<<j<<' '<<k1<<' '<<b1<<endl;
	if(k1*x1[j]+b1!=y1[j]*(x2[i]-x1[i])&&k1*x2[j]+b1!=y2[j]*(x2[i]-x1[i])) return mp(1<<30,1<<30);
	if(k1*x1[j]+b1==y1[j]*(x2[i]-x1[i])){
		if(x1[j]<min(x1[i],x2[i])||x1[j]>max(x1[i],x2[i])||y1[j]<min(y1[i],y2[i])||y1[j]>max(y1[i],y2[i])) return mp(1<<30,1<<30);
		return mp(x1[j],y1[j]);
	}
	else{
		if(x2[j]<min(x1[i],x2[i])||x2[j]>max(x1[i],x2[i])||y2[j]<min(y1[i],y2[i])||y2[j]>max(y1[i],y2[i])) return mp(1<<30,1<<30);
		return mp(x2[j],y2[j]);
	}
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(y2[j]-y1[j])-(y2[i]-y1[i])*(x2[j]-x1[j])==0) return false;
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<0) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
//	cout<<"p "<<p1.fi<<' '<<p1.se<<' '<<p2.fi<<' '<<p2.se<<endl;
	if(p1.fi==(1<<30)||p2.fi==(1<<30)) return false;
	ll dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		for(int i=1;i<=3;i++) if(x1[i]>x2[i]) swap(x1[i],x2[i]),swap(y1[i],y2[i]);
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-10;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1<<30,-1<<30);
	}
	if(x1[j]==x2[j]){
		if(fabs(x1[j]-x1[i])>eps&&fabs(x1[j]-x2[i])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			ld tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])-eps||tmp>max(y1[j],y2[j])+eps) return mp(-1<<30,-1<<30);
			return mp(x1[j],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	if(x1[i]==x2[i]){
		if(fabs(x1[i]-x1[j])>eps&&fabs(x1[i]-x2[j])>eps) return mp(-1<<30,-1<<30);
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			ld tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])-eps||tmp>max(y1[i],y2[i])+eps) return mp(-1<<30,-1<<30);
			return mp(x1[i],tmp);
		}
		else return mp(-1<<30,-1<<30);
	}
	ld k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	ld k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	if(k1==k2) return mp(-1,-1);
	ld tmpx=(b2-b1)/(k1-k2);
	if(fabs(tmpx-x1[j])>eps&&fabs(tmpx-x2[j])>eps) return mp(-1<<30,-1<<30);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1<<30,-1<<30);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1<<30,-1<<30);
	ld tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1<<30,-1<<30);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1<<30,-1<<30);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<-eps) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi==(-1<<30)||p2.fi==(-1<<30)) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(16*min(dis1,dis2)<max(dis1,dis2)) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<double,double> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-9;
int n;
double x1[5],x2[5],y1[5],y2[5];

double dist(pdd x,pdd y){return sqrt((x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se));}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1,-1);
	}
	if(x1[j]==x2[j]){
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			double tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])||tmp>max(y1[j],y2[j])) return mp(-1,-1);
			return mp(x1[j],tmp);
		}
		else return mp(-1,-1);
	}
	if(x1[i]==x2[i]){
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			double tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])||tmp>max(y1[i],y2[i])) return mp(-1,-1);
			return mp(x1[i],tmp);
		}
		else return mp(-1,-1);
	}
	double k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	double k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	if(k1==k2) return mp(-1,-1);
	double tmpx=(b2-b1)/(k1-k2);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1,-1);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1,-1);
	double tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1,-1);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1,-1);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<0) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi<0||p2.fi<0) return false;
	double dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(min(dis1,dis2)/max(dis1,dis2)<0.25) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(min(dis1,dis2)/max(dis1,dis2)<0.25) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)){
						fl=1;
					}
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>

#define y1 dmytsdy
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> pdd;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const double eps=1e-9;
int n;
ld x1[5],x2[5],y1[5],y2[5];

ld dist(pdd x,pdd y){return (x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se);}

pdd getp(int i,int j){
	if(x1[i]==x2[i]&&x1[j]==x2[j]){
		return mp(-1,-1);
	}
	if(x1[j]==x2[j]){
		if(min(x1[i],x2[i])<=x1[j]&&x1[j]<=max(x1[i],x2[i])){
			ld tmp=(y2[i]-y1[i])/(x2[i]-x1[i])*x1[j]+(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
			if(tmp<min(y1[j],y2[j])-eps||tmp>max(y1[j],y2[j])+eps) return mp(-1,-1);
			return mp(x1[j],tmp);
		}
		else return mp(-1,-1);
	}
	if(x1[i]==x2[i]){
		if(min(x1[j],x2[j])<=x1[i]&&x1[i]<=max(x1[j],x2[j])){
			ld tmp=(y2[j]-y1[j])/(x2[j]-x1[j])*x1[i]+(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
			if(tmp<min(y1[i],y2[i])-eps||tmp>max(y1[i],y2[i])+eps) return mp(-1,-1);
			return mp(x1[i],tmp);
		}
		else return mp(-1,-1);
	}
	ld k1=(y2[i]-y1[i])/(x2[i]-x1[i]),b1=(x2[i]*y1[i]-x1[i]*y2[i])/(x2[i]-x1[i]);
	ld k2=(y2[j]-y1[j])/(x2[j]-x1[j]),b2=(x2[j]*y1[j]-x1[j]*y2[j])/(x2[j]-x1[j]);
	if(k1==k2) return mp(-1,-1);
	ld tmpx=(b2-b1)/(k1-k2);
	if(tmpx<min(x1[i],x2[i])-eps||tmpx>max(x1[i],x2[i])+eps) return mp(-1,-1);
	if(tmpx<min(x1[j],x2[j])-eps||tmpx>max(x1[j],x2[j])+eps) return mp(-1,-1);
	ld tmpy=k1*tmpx+b1;
	if(tmpy<min(y1[i],y2[i])-eps||tmpy>max(y1[i],y2[i])+eps) return mp(-1,-1);
	if(tmpy<min(y1[j],y2[j])-eps||tmpy>max(y1[j],y2[j])+eps) return mp(-1,-1);
	return mp(tmpx,tmpy);
}

bool getans(int i,int j){
	if((x2[i]-x1[i])*(x2[j]-x1[j])+(y2[i]-y1[i])*(y2[j]-y1[j])<-eps) return false;
	int now=0;
	for(int k=1;k<=3;k++) if(i!=k&&j!=k) now=k;
	pdd p1=getp(i,now),p2=getp(j,now);
	if(p1.fi<0||p2.fi<0) return false;
	ld dis1=dist(p1,mp(x1[i],y1[i])),dis2=dist(p1,mp(x2[i],y2[i]));
	if(min(dis1,dis2)/max(dis1,dis2)<(ld)1/16-eps) return false;
	dis1=dist(p2,mp(x1[j],y1[j])),dis2=dist(p2,mp(x2[j],y2[j]));
	if(min(dis1,dis2)/max(dis1,dis2)<(ld)1/16-eps) return false;
	return true;
}

int main(){
	int T=readint();
	while(T--){
		for(int i=1;i<=3;i++) x1[i]=readint(),y1[i]=readint(),x2[i]=readint(),y2[i]=readint();
		bool fl=0;
		for(int i=1;i<=3;i++){
			for(int j=i+1;j<=3;j++){
				if(x1[i]==x2[j]&&y1[i]==y2[j]){
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x2[i]==x1[j]&&y2[i]==y1[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]);
				}
				if(x2[i]==x2[j]&&y2[i]==y2[j]){
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
					if(getans(i,j)) fl=1;
					swap(x1[i],x2[i]),swap(y1[i],y2[i]),swap(x1[j],x2[j]),swap(y1[j],y2[j]);
				}
				if(x1[i]==x1[j]&&y1[i]==y1[j]){
					if(getans(i,j)) fl=1;
				}
			}
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <complex>
#include <numeric>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

#define all(a)		(a).begin(),(a).end()
#define sz(a)		int((a).size())
#define FOR(i,a,b)	for(int i=a;i<b;++i)
#define REP(i,n)	FOR(i,0,n)
#define UN(v)		sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)		memset(a,b,sizeof a)
#define pb			push_back
#define X			first
#define Y			second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

ll det(int a, int b, int c, int d) { return a * ll(d) - b * ll(c); }

bool ch(int x0, int x1, int x) {
	x1 -= x0, x -= x0;
	x0 = min(x, x1 - x);
	x1 = max(x, x1 - x);
	if (x0 < 0 || 4 * x0 < x1) return false;
	return true;
}

struct line {
	int x1, y1, x2, y2;
	void read() { scanf("%d%d%d%d", &x1, &y1, &x2, &y2); }
	pii p1(){ return pii(x1, y1); }
	pii p2(){ return pii(x2, y2); }
	void rev() {
		swap(x1, x2);
		swap(y1, y2);
	}
	void shift(int x, int y) { x1 -= x, y1 -= y, x2 -= x, y2 -= y; }
	bool contains(const pii &p) { return det(x1 - p.X, y1 - p.Y, x2 - p.X, y2 - p.Y) == 0; }
	bool check(int x, int y) {
		return ch(min(x1, x2), max(x1, x2), x) && ch(min(y1, y2), max(y1, y2), y);
	}
};

inline ll d2(int x, int y){ return x * ll(x) + y * ll(y); }

bool solve(line a, line b, line c) {
	if (a.p1() == b.p1() || a.p1() == b.p2()) a.rev();
	if (b.p2() == a.p2()) b.rev();
	if (a.p2() != b.p1()) return false;
	pii q = a.p2();
	a.shift(q.X, q.Y);
	b.shift(q.X, q.Y);
	c.shift(q.X, q.Y);
	ll A = d2(a.x1, a.y1);
	ll B = d2(b.x2, b.y2);
	ll D = d2(a.x1 - b.x2, a.y1 - b.y2);
	if (D == 0 || A + B < D) return false;
	if (!a.contains(c.p1())) c.rev();
	if (!a.contains(c.p1()) || !b.contains(c.p2())) return false;
	return a.check(c.x1, c.y1) && b.check(c.x2, c.y2);
}

int main(){
	#ifdef LocalHost
	freopen("x.in","r",stdin);
	freopen("x.out","w",stdout);
	#endif
	int T;
	for (cin >> T; T --> 0; ) {
		line a, b, c;
		a.read();
		b.read();
		c.read();
		puts(
			solve(a, b, c) ||
			solve(a, c, b) ||
			solve(b, a, c) ||
			solve(b, c, a) ||
			solve(c, a, b) ||
			solve(c, b, a) ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define swp(a,b) {a^=b;b^=a;a^=b;}
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define dif(x) ((x).yy-(x).xx)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) (x).begin(),(x).end()
#define exist(a,x) find(all(a),x)!=a.end()
#define ub(a,x) upper_bound(all(a),x)
#define lb(a,x) lower_bound(all(a),x)
#define inv(n) power((n), mod - 2)
#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)
#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)
#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
const ld PI = 3.14159265359;
//const int mod = 998244353;
const int mod = 1000000007;
const li inf = 4000000000000000001ll;

using namespace __gnu_pbds;
template <class T> using oset = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <class T> using omset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;

inline int power(li _a, int _n)
{
        li _c = 1;
        while (_n>0)
        {
                if (_n % 2) _c = _c * _a%mod;
                _a = _a * _a%mod;
                _n/=2;
        }
        return _c;
}

inline int geom(li _a, int _n) //suma 1 + a + a^2 + ... + a^(n-1)
{
    if (_a == 0) return 0;
        if (_a == 1) return _n;
        return ((li)power(_a, _n) - 1) * inv(_a - 1) % mod;
}

pli _r;

li bigmod(li _a, li _b, li _m) //ogromni mod
{
    if (_a==0) return 0;
    if (_a%2==1) return (_b + 2*bigmod(_a/2,_b,_m))%_m;
    return 2*bigmod(_a/2,_b,_m)%_m;
}

void euklid(li _a, li _b)
{
    if (_b==1)
    {
        _r = mp(1,-_a+1);
        return;
    }

    euklid(_b,_a%_b); //cout<<r.xx<<" "<<r.yy<<endl;
    _r=mp(_r.yy,_r.xx-_r.yy*(_a/_b));
}

li kinez(li _x, li _a, li _y, li _b)
{
    if (_x==_y) return _x;
    if (_a>_b) {swap(_a,_b); swap(_x,_y);}

    euklid(_b,_a); (_r.xx*=(_x-_y))%=(_a*_b);
    return (bigmod(_b,_r.xx,_a*_b)+_y)%(_a*_b);
}

inline li sum(int _n) {return ((li)_n*(_n+1))/2;}

inline li kv(int _n) {return ((li)_n*(_n+1)*(2*_n+1))/6;}

//Note to self: Check for overflow

struct line
{
    pii p,q;
};

//debug:

inline void coutline(line a)
{
    cout<<" "<<a.p.xx<<" "<<a.p.yy<<" "<<a.q.xx<<" "<<a.q.yy<<endl;
}

inline void coutpoint(pii p)
{
    cout<<" "<<p.xx<<" "<<p.yy<<endl;
}

//

bool viktor(pii a, pii b)
{
    return (li)a.xx*b.xx + (li)a.yy*b.yy < 0 && (li)a.xx*b.yy != (li)a.yy*b.xx;
}

bool kol(pii a, pii b, pii c)
{
    return (li)(a.xx-c.xx)*(b.yy-c.yy) == (li)(a.yy-c.yy)*(b.xx-c.xx);
}

bool lose(int r1, int r2)
{
    if (r1<0)
    {
        r1=-r1;
        r2=-r2;
    }

    //cout<<r1<<" "<<r2<<endl;
    return 4*r1 <r2 || 4*r2<r1;
}

bool pitaj(pii A, pii B, pii C, pii D, pii E)
{
    /*coutpoint(A);
    coutpoint(B);
    coutpoint(C);
    coutpoint(D);
    coutpoint(E);*/

    if (lose(D.xx-A.xx,C.xx-D.xx)) return false;
    if (lose(E.xx-B.xx,C.xx-E.xx)) return false;
    if (lose(D.yy-A.yy,C.yy-D.yy)) return false;
    if (lose(E.yy-B.yy,C.yy-E.yy)) return false;
    return true;
}

bool check(pii A, pii B, pii C, line c)
{
    if (viktor({C.xx-A.xx,C.yy-A.yy},{C.xx-B.xx,C.yy-B.yy})) return false;
    if (kol(A,c.p,C) && kol(B,c.q,C)) return pitaj(A,B,C,c.p,c.q);
    if (kol(A,c.q,C) && kol(B,C,c.p)) return pitaj(A,B,C,c.q,c.p);

    return false;
}

bool AAAAAAAAAAAAAAAAA(line a, line b, line c)
{

    if (a.p==b.p) return check(a.q,b.q,a.p,c);
    if (a.p==b.q) return check(a.q,b.p,a.p,c);
    if (a.q==b.p) return check(a.p,b.q,a.q,c);
    if (a.q==b.q) return check(a.p,b.p,a.q,c);

    if (c.p==b.p) return check(c.q,b.q,c.p,a);
    if (c.p==b.q) return check(c.q,b.p,c.p,a);
    if (c.q==b.p) return check(c.p,b.q,c.q,a);
    if (c.q==b.q) return check(c.p,b.p,c.q,a);

    if (c.p==a.p) return check(c.q,a.q,c.p,b);
    if (c.p==a.q) return check(c.q,a.p,c.p,b);
    if (c.q==a.p) return check(c.p,a.q,c.q,b);
    if (c.q==a.q) return check(c.p,a.p,c.q,b);

    return false;
}

int main()
{
    FAST;

    int t; cin>>t;
    while (t--)
    {
        line a,b,c;
        cin>>a.p.xx>>a.p.yy>>a.q.xx>>a.q.yy;
        cin>>b.p.xx>>b.p.yy>>b.q.xx>>b.q.yy;
        cin>>c.p.xx>>c.p.yy>>c.q.xx>>c.q.yy;

        if (AAAAAAAAAAAAAAAAA(a,b,c)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

//Note to self: Check for overflow