#include using namespace atcoder; using mint = modint998244353; const long long MOD = 998244353; // using mint = modint1000000007; // const long long MOD = 1000000007; // using mint = modint;//mint::set_mod(MOD); #include #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define repeq(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); i++) #define repreq(i, a, b) for (ll i = (ll)(a); i >= (ll)(b); i--) #define endl '\n' // fflush(stdout); #define cYes cout << "Yes" << endl #define cNo cout << "No" << endl #define sortr(v) sort(v, greater<>()) #define pb push_back #define pob pop_back #define mp make_pair #define mt make_tuple #define FI first #define SE second #define ALL(v) (v).begin(), (v).end() #define INFLL 3000000000000000100LL #define INF 1000000100 #define PI acos(-1.0L) #define TAU (PI * 2.0L) using namespace std; typedef long long ll; typedef pair Pll; typedef tuple Tlll; typedef vector Vi; typedef vector VVi; typedef vector Vl; typedef vector VVl; typedef vector VVVl; typedef vector VTlll; typedef vector Vm; typedef vector VVm; typedef vector Vs; typedef vector Vd; typedef vector Vc; typedef vector Vb; typedef vector VPll; typedef priority_queue PQl; typedef priority_queue, greater> PQlr; /* inout */ ostream &operator<<(ostream &os, mint const &m) { os << m.val(); return os; } istream &operator>>(istream &is, mint &m) { long long n; is >> n, m = n; return is; } template ostream &operator<<(ostream &os, const vector &v) { int n = v.size(); rep(i, 0, n) { os << v[i] << " \n"[i == n - 1]; } return os; } template ostream &operator<<(ostream &os, const vector> &v) { int n = v.size(); rep(i, 0, n) os << v[i]; return os; } template ostream &operator<<(ostream &os, pair const &p) { os << p.first << ' ' << p.second; return os; } template ostream &operator<<(ostream &os, const map &ma) { for (auto &[key, val] : ma) { os << key << ':' << val << '\n'; } return os; } template ostream &operator<<(ostream &os, const set &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? ' ' : '\n'); itr++; } return os; } template ostream &operator<<(ostream &os, multiset &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? ' ' : '\n'); itr++; } return os; } template ostream &operator<<(ostream &os, queue q) { while (q.size()) { os << q.front(); q.pop(); os << " \n"[q.empty()]; } return os; } template ostream &operator<<(ostream &os, stack st) { vector v; while (st.size()) { v.push_back(st.top()); st.pop(); } reverse(ALL(v)); os << v; return os; } template ostream &operator<<(ostream &os, priority_queue pq) { vector v; while (pq.size()) { v.push_back(pq.top()); pq.pop(); } os << v; return os; } template istream &operator>>(istream &is, vector &v) { for (T &in : v) is >> in; return is; } template istream &operator>>(istream &is, pair &p) { is >> p.first >> p.second; return is; } /* useful */ template int SMALLER(vector &a, T x) { return lower_bound(a.begin(), a.end(), x) - a.begin(); } template int orSMALLER(vector &a, T x) { return upper_bound(a.begin(), a.end(), x) - a.begin(); } template int BIGGER(vector &a, T x) { return a.size() - orSMALLER(a, x); } template int orBIGGER(vector &a, T x) { return a.size() - SMALLER(a, x); } template int COUNT(vector &a, T x) { return upper_bound(ALL(a), x) - lower_bound(ALL(a), x); } template bool chmax(T &a, S b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, S b) { if (a > b) { a = b; return 1; } return 0; } template void press(T &v) { v.erase(unique(ALL(v)), v.end()); } template vector zip(vector a) { int n = a.size(); pair p[n]; vector v(n); for (int i = 0; i < n; i++) p[i] = make_pair(a[i], i); sort(p, p + n); int w = 0; for (int i = 0; i < n; i++) { if (i && p[i].first != p[i - 1].first) w++; v[p[i].second] = w; } return v; } template vector vis(vector &v) { vector S(v.size() + 1); rep(i, 1, S.size()) S[i] += v[i - 1] + S[i - 1]; return S; } template T ceil_div(T a, T b) { if (b < 0) a = -a, b = -b; return (a >= 0 ? (a + b - 1) / b : a / b); } template T floor_div(T a, T b) { if (b < 0) a = -a, b = -b; return (a >= 0 ? a / b : (a - b + 1) / b); } ll dtoll(double d, int g) { return round(d * pow(10, g)); } const double EPS = 1e-10; void init() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout.precision(12); cout << fixed; } // do {} while (next_permutation(ALL(vec))); /********************************** START **********************************/ void sol(); int main() { init(); int q = 1; cin >> q; while (q--) sol(); return 0; } /********************************** SOLVE **********************************/ // #define EPS (1e-10) // #define PI (acos(-1)) using ll = long long; using ull = unsigned long long; using ld = long double; using vi = vector; using vvi = vector; using vvvi = vector; using vll = vector; using vvll = vector; using vvvll = vector; using vld = vector; using vvld = vector; using vvvld = vector; using vs = vector; using pll = pair; using vp = vector; // point using P = complex; // two points: line using L = array; // circle struct C { P c; ld r; C() : c({0, 0}), r(0) {} C(const P &c_, ld r_) : c(c_), r(r_) {} C(ld x_, ld y_, ld r_) : c({x_, y_}), r(r_) {} }; using VP = vector

; using VC = vector; void Pin(P &a, ld b, ld c) { a.real(b); a.imag(c); } void Lin(L &a, P b, P c) { a[0] = b; a[1] = c; } ostream &operator<<(ostream &os, P const &A) { os << A.real() << ' ' << A.imag(); return os; } namespace std { bool operator<(const P &a, const P &b) { return arg(a) < arg(b); } } // namespace std ld cross(const P &a, const P &b) { return imag(conj(a) * b); } ld dot(const P &a, const P &b) { return real(conj(a) * b); } // 線分ABをs:tに内分する点 P bun(P A, P B, double s, double t) { complex S(t / (s + t)), T(s / (s + t)); return A * S + B * T; } // a->b->cの進行方向 int ccw(P a, P b, P c) { b -= a; c -= a; if (cross(b, c) > 0) return 1; // counterclockwise a--b//c if (cross(b, c) < 0) return -1; // clockwise a--b\\c if (dot(b, c) < 0) return 2; // c--a--b on line if (norm(b) < norm(c)) return -2; // a--b--c on line return 0; // a--c--b on line } // 直線-直線交差判定 bool intersectLL(const L &l, const L &m) { return abs(cross(l[1] - l[0], m[1] - m[0])) > EPS // non-parallel || abs(cross(l[1] - l[0], m[1] - l[0])) < EPS; // same line } // 直線-線分交差判定 bool intersectLS(const L &l, const L &s) { return cross(l[1] - l[0], s[0] - l[0]) * // s[0] is left of l cross(l[1] - l[0], s[1] - l[0]) < EPS; // s[1] is right of l } // 線分-線分交差判定 bool intersectSS(const L &s, const L &t) { return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 && ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0; } // 点∈直線の判定 bool intersectLP(const L &l, const P &p) { return abs(cross(l[1] - p, l[0] - p)) < EPS; } // 点∈線分の判定 bool intersectSP(const L &s, const P &p) { // triangle inequality return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS; } // 点の直線への射影 P projection(const L &l, const P &p) { ld t = dot(p - l[0], l[1] - l[0]) / norm(l[1] - l[0]); return l[0] + t * (l[1] - l[0]); } // 点の直線に対する鏡映 P reflection(const L &l, const P &p) { return p + (projection(l, p) - p) * 2.L; } // 点-直線の距離 ld distanceLP(const L &l, const P &p) { return abs(p - projection(l, p)); } // 直線-直線の距離 非平行か同一なら0 ld distanceLL(const L &l, const L &m) { return intersectLL(l, m) ? 0 : distanceLP(l, m[0]); } // 直線-線分の距離 ld distanceLS(const L &l, const L &s) { return intersectLS(l, s) ? 0 : min(distanceLP(l, s[0]), distanceLP(l, s[1])); } // 点-線分の距離 ld distanceSP(const L &s, const P &p) { const P r = projection(s, p); if (intersectSP(s, r)) return abs(r - p); return min(abs(s[0] - p), abs(s[1] - p)); } // 線分-線分の距離 ld distanceSS(const L &s, const L &t) { if (intersectSS(s, t)) return 0; return min({distanceSP(s, t[0]), distanceSP(s, t[1]), distanceSP(t, s[0]), distanceSP(t, s[1])}); } // 2直線の交点 平行な場合は例外 P crosspoint(const L &l, const L &m) { ld A = cross(l[1] - l[0], m[1] - m[0]); ld B = cross(l[1] - l[0], l[1] - m[0]); return m[0] + B / A * (m[1] - m[0]); } // 2円の交点 一致する場合は例外 VP crosspoint(C a, C b) { ld dist = abs(a.c - b.c); ld rdist = abs(a.r - b.r); assert(dist >= EPS || rdist >= EPS); // 外接する if (abs(dist - (a.r + b.r)) < EPS) { return {(b.r * a.c + a.r * b.c) / (a.r + b.r)}; } // 内接する if (abs(dist - rdist) < EPS) { return {(-b.r * a.c + a.r * b.c) / (a.r - b.r)}; } // 離れている、内包する if (dist > a.r + b.r || dist < rdist) { return {}; } // 交わる 中心を0と1に規格化 // 最後に足す P movp = a.c; a.c = {0.L, 0.L}; b.c -= movp; // 最後に掛ける P movm = b.c; b.c = {1.L, 0.L}; a.r /= abs(movm); b.r /= abs(movm); ld x = (a.r * a.r - b.r * b.r + 1) / 2; ld y = sqrt(a.r * a.r - x * x); P cr1 = {x, y}; P cr2 = {x, -y}; cr1 = cr1 * movm + movp; cr2 = cr2 * movm + movp; // 元に戻す return {cr1, cr2}; } // 円盤の最大の重なりの個数 O(n^3) ll maxOverlap(const VC &vc) { ll n = vc.size(); if (!n) return 0; ll ret = 1; VP pts; for (auto &&e : vc) { pts.emplace_back(e.c); } for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { VP cp = crosspoint(vc[i], vc[j]); pts.insert(pts.end(), cp.begin(), cp.end()); } } for (auto &&e : pts) { ll tmp = 0; for (auto &&ee : vc) { tmp += (abs(e - ee.c) < ee.r + EPS); } if (ret < tmp) ret = tmp; } return ret; } // 多角形の面積 ld Area(const VP &p) { ll ret = 0; for (int i = 1; i + 1 < (int)p.size(); i++) { ret += round(cross(p[i] - p[0], p[i + 1] - p[0])); } return (ld)abs(ret) / 2; } // 凸性判定 点列は時計/反時計 bool isConvex(const VP &p) { int n = p.size(); assert(n >= 3); int cnt[5] = {}; for (int i = 0; i < n; i++) { cnt[ccw(p[i], p[(i + 1) % n], p[(i + 2) % n]) + 2]++; } return cnt[1] == 0 || cnt[3] == 0; } // 凸包 時計回り VP ConvexHull(VP p) { sort(p.begin(), p.end(), [](const auto &l, const auto &r) { return real(l) != real(r) ? real(l) < real(r) : imag(l) < imag(r); }); int n = p.size(); if (n < 3) return p; VP upper, lower; upper.reserve(n); lower.reserve(n); int sz = 0; for (int i = 0; i < n; i++) { upper.emplace_back(p[i]); sz++; while (sz >= 3 && ccw(upper[sz - 3], upper[sz - 2], upper[sz - 1]) == 1) { upper.erase(upper.end() - 2); sz--; } } sz = 0; for (int i = n - 1; i >= 0; i--) { lower.emplace_back(p[i]); sz++; while (sz >= 3 && ccw(lower[sz - 3], lower[sz - 2], lower[sz - 1]) == 1) { lower.erase(lower.end() - 2); sz--; } } upper.pop_back(); lower.pop_back(); copy(lower.begin(), lower.end(), back_inserter(upper)); return upper; } // 多角形が点pを含むか 点列は時計/反時計 内2, 辺上1, 外0 O(V) int PointInPolygon(const VP &g, const P &p) { int n = g.size(); ld r = 0; assert(n >= 2); for (int i = 0; i < n; i++) { if (ccw(g[i], g[(i + 1) % n], p) == 0) return 1; r += arg((g[(i + 1) % n] - p) / (g[i] - p)); } return abs(r) > PI ? 2 : 0; } // キャリパー法(Rotating Calipers法) // 凸多角形を回転しながら走査し、最遠点対を求める ld Diameter(const VP &p) { auto qs = ConvexHull(p); reverse(qs.begin(), qs.end()); int n = qs.size(); if (n == 2) return abs(qs[0] - qs[1]); int i = 0, j = 0; auto cmp = [](const P &a, const P &b) { return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag(); }; for (int k = 0; k < n; k++) { if (cmp(qs[k], qs[i])) i = k; if (cmp(qs[j], qs[k])) j = k; } ld ret = 0; int si = i, sj = j; while (i != sj || j != si) { ret = max(ret, abs(qs[i] - qs[j])); if (cross(qs[(i + 1) % n] - qs[i], qs[(j + 1) % n] - qs[j]) < 0) { i = (i + 1) % n; } else { j = (j + 1) % n; } } return ret; } // 凸多角形の切断 // 凸多角形pを直線lで切断したときの面積(切断の向きの左側) // https://onlinejudge.u-aizu.ac.jp/services/room.html#GEOMETRY_20231005/problems/M ld ConvexCut(const VP &p, const L &l) { int n = p.size(); VP q; for (int i = 0; i < n; i++) { P a = p[i], b = p[(i + 1) % n]; if (ccw(l[0], l[1], a) != -1) q.emplace_back(a); if (ccw(l[0], l[1], a) * ccw(l[0], l[1], b) < 0) { if (abs(cross(l[1] - l[0], b - a)) < EPS) { q.emplace_back(a); } else { q.emplace_back(crosspoint(L{a, b}, l)); } } } ld ret = 0; for (int i = 0; i < (int)q.size(); i++) { ret += cross(q[i], q[(i + 1) % q.size()]); } return abs(ret) / 2; } // 2円の共通接線の本数(0, 1, 2, 3, 4) // https://onlinejudge.u-aizu.ac.jp/services/room.html#GEOMETRY_20231005/problems/N ll tangentlines(C a, C b) { ld dist = abs(a.c - b.c); ld rdist = abs(a.r - b.r); if (dist < rdist) return 0; if (abs(dist - rdist) < EPS) return 1; if (dist < a.r + b.r) return 2; if (abs(dist - a.r - b.r) < EPS) return 3; return 4; } // 三角形の内接円 C InCircle(P a, P b, P c) { ld a1 = abs(b - c); ld a2 = abs(c - a); ld a3 = abs(a - b); ld s = (a1 + a2 + a3) / 2; ld r = sqrtl(s * (s - a1) * (s - a2) * (s - a3)) / s; P p = (a1 * a + a2 * b + a3 * c) / (a1 + a2 + a3); return C(p, r); } void sol() { P p0, p1, q0, q1; rep(i, 0, 4) { ld x, y; cin >> x >> y; if (i == 0) Pin(p0, x, y); if (i == 1) Pin(p1, x, y); if (i == 2) Pin(q0, x, y); if (i == 3) Pin(q1, x, y); } L l0 = {p0, q0}, l1 = {p1, q1}; if (!intersectLL(l0, l1)) { cout << "No" << endl; return; } P c = crosspoint(l0, l1); double d0 = abs(c - q0) / abs(c - p0); double d1 = abs(c - q1) / abs(c - p1); if (d0 >= 1 || d1 >= 1) { cout << "No" << endl; return; } if (abs(d0 - d1) < EPS) { cout << "Yes" << endl; } else { cout << "No" << endl; } }