#include #include #include using Real = boost::rational; struct Point { Point() {} Real x = 0, y = 0; }; bool operator==(Point lhs, Point rhs) { return lhs.x == rhs.x && lhs.y == rhs.y; } struct Line { Real m, c; bool valid = true; Line() {} Line(Point lhs, Point rhs) { if (lhs.x - rhs.x == 0) { valid = false; m = lhs.x; } else { m = (lhs.y - rhs.y) / (lhs.x - rhs.x); c = lhs.y - m * lhs.x; } } auto operator<=>(const Line& lhs) const = default; }; std::pair intersect(Line lhs, Line rhs) { if (!lhs.valid && !rhs.valid) return {false, Point()}; if (!lhs.valid) { Point p; p.x = lhs.m; p.y = rhs.m * p.x + rhs.c; return {true, p}; } else if (!rhs.valid) { Point p; p.x = rhs.m; p.y = lhs.m * p.x + lhs.c; return {true, p}; } if (lhs.m == rhs.m) return {false, Point()}; Point p; p.x = (lhs.c - rhs.c) / (rhs.m - lhs.m); p.y = lhs.m * p.x + lhs.c; return {true, p}; } Real dist(Point lhs, Point rhs) { return (lhs.x - rhs.x) * (lhs.x - rhs.x) + (lhs.y - rhs.y) * (lhs.y - rhs.y); } void solve() { std::vector points(4); for (int i = 0; i < 4; i++) { long long x, y; std::cin >> x >> y; points[i].x = x; points[i].y = y; } if (points[0] == points[2] && points[1] == points[3]) { std::cout << "Yes" << '\n'; return; } if (dist(points[0], points[1]) <= dist(points[2], points[3])) { std::cout << "No" << '\n'; return; } Line l1(points[0], points[1]); Line l2(points[2], points[3]); bool ok = false; if (!l1.valid && !l2.valid) { ok = true; } else if (l1.valid && l2.valid) { ok = l1.m == l2.m; } std::cout << (ok ? "Yes" : "No") << '\n'; } int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(16); int t = 1; std::cin >> t; while (t--) solve(); }