#include using namespace std; const int MaxN = (int)1e5 + 10; const int MOD = (int)1e9 + 7; const long long INF = 1e14; typedef long double dbl; struct Point { dbl x, y, z; Point(dbl _x = 0.0, dbl _y = 0.0, dbl _z = 0.0) : x(_x), y(_y), z(_z) { } dbl dist(const Point &o) const { return sqrtl((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y) + (z - o.z) * (z - o.z)); } void read() { cin >> x >> y >> z; } }; dbl checkInside(const Point ¢re, const Point &o, dbl r) { return centre.dist(o) <= r; } bool visible(const Point &a, const Point &b, const Point &c, dbl rad) { dbl l = 0, r = 1, res = 0; for (int it = 0; it < 80; ++it) { dbl ll = l + (r - l) / 3.0; dbl rr = r - (r - l) / 3.0; Point fl = Point(a.x + ll * (b.x - a.x), a.y + ll * (b.y - a.y), a.z + ll * (b.z - a.z)); Point fr = Point(a.x + rr * (b.x - a.x), a.y + rr * (b.y - a.y), a.z + rr * (b.z - a.z)); dbl ul = c.dist(fl), ur = c.dist(fr); if (ul < ur) { r = rr; res = ur; } else { l = ll; res = ul; } } return res <= rad; } void solve() { Point p1, p2, dir, centre; dbl rad; p1.read(); p2.read(); dir.read(); centre.read(); cin >> rad; dbl l = 0, r = 2e9; for (int it = 0; abs(r - l) > 1e-7; ++it) { dbl t = (l + r) / 2.0; Point p20 = Point(p2.x + dir.x * t, p2.y + dir.y * t, p2.z + dir.z * t); if (visible(p1, p20, centre, rad)) { l = t; } else { r = t; } } cout.precision(10); cout << fixed << (l + r) / 2.0 << "\n"; } int main() { // freopen("input.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; assert (1 <= t && t <= 1e5); while (t --> 0) { solve(); } return 0; }