Problem:
流れ星に願いを
謎の組織 JAG (Japanese Alumni Group) では定期的に会議を開いている．ある日の議題は「近日行われる ICPC (International Collegiate Programming Contest) 国内予選で参加チームが力を発揮できるようにするには」であった．会議の結論として流れ星に各チームの健闘を祈ることになり，彼らは本部を置く建物の屋上に出た．
彼らが屋上に出ると，空には $n$ 個の流れ星が見えていた．流れ星は3次元空間上の球として表され，$1$ から $n$ の番号が割り振られている．星に詳しいメンバーにより，各流れ星は一定の速度で直線的に移動すると同時に，一定の速度で半径が小さくなっていくとみなせることが分かった．実際に測定してみたところ，各流れ星の初期位置 $(px_i, py_i, pz_i)$，移動速度 $(vx_i, vy_i, vz_i)$，初期半径 $r_i$，消滅速度 $vr_i$ が分かった．これは流れ星 $i$ が時刻 $t$ ($t \geq 0$) で中心座標 $(px_i + t vx_i, py_i + t vy_i, pz_i + t vz_i)$，半径 $r_i - t vr_i$ の球となる事を表している．流れ星は，半径が 0 になった瞬間に自然消滅してしまう．また，2つの流れ星が接触した場合はどちらの流れ星も消滅してしまう．
あなたの仕事は，効率よく参加チームの健闘を祈ることができるように，各流れ星が消滅するまでの時間を求めることである．彼らの中には卓越した視力の持ち主がいるため，情報が与えられた $n$ 個以外に流れ星が存在する可能性については考慮しなくても良い．加えて，彼らは非常に効率よく流れ星の観測を行ったため，観測にかかった時間は無視できるほど小さいと考えて良い．
Input
入力は複数のデータセットから構成され，1つの入力に含まれるデータセットの数は100以下である．
各データセットの形式は次の通りである．
$n$
$px_1$ $py_1$ $pz_1$ $vx_1$ $vy_1$ $vz_1$ $r_1$ $vr_1$
...
$px_n$ $py_n$ $pz_n$ $vx_n$ $vy_n$ $vz_n$ $r_n$ $vr_n$
$n$ は流れ星の数を表す整数であり，$1$ 以上 $200$ 以下と仮定して良い．
続く $n$ 行には流れ星の情報が与えられる．
各行は小数点以下4桁で表される8つの値を含み，$(px_i, py_i, pz_i)$ は流れ星 $i$ の初期位置を，$(vx_i, vy_i, vz_i)$ は移動速度を，$r_i$ は初期半径を，$vr_i$ は消滅速度をそれぞれ表す．
与えられる値について，$-1{,}000 \leq px_i \leq 1{,}000$，$-1{,}000 \leq py_i \leq 1{,}000$，$-1{,}000 \leq pz_i \leq 1{,}000$，$-100 \leq vx_i \leq 100$， $-100 \leq vy_i \leq 100$， $-100 \leq vz_i \leq 100$，$1 \leq r_i \leq 100$，$1 \leq vr_i \leq 100$ であると仮定して良い．
また，与えられるデータセットについて以下を仮定して良い．
ある1つの流れ星の初期半径が $10^{-8}$ 変化しても，接触する星のペアの集合は変わらない
ある1つの流れ星が接触により消滅しないと仮定しても，$10^{-8}$ 以内の時間で2つ以上の流れ星に接触したり，他の流れ星と接触する時刻から$10^{-8}$以内に自然消滅することはない
初期状態ではどの2つの流れ星も重なっておらず，$10^{-8}$以上の距離を空けている
時刻 $t < 10^{-8}$ ではどの2つの流れ星も接触しない
$n = 0$ は入力の終わりを示す．これはデータセットには含めない．
Output
各データセットについて，各流れ星が消滅するまでの時間を流れ星1から順にそれぞれ1行に出力しなさい．
出力には$10^{-8}$を超える絶対誤差があってはならない．
それ以外の余計な文字を出力してはならない．
Sample Input
1
0.0000 0.0000 0.0000 2.0000 0.0000 0.0000 4.0000 1.0000
2
0.0000 0.0000 0.0000 2.0000 0.0000 0.0000 4.0000 1.0000
10.0000 0.0000 0.0000 -2.0000 0.0000 0.0000 4.0000 1.0000
5
-10.0000 0.0000 0.0000 10.0000 0.0000 0.0000 2.0000 1.0000
-5.0000 0.0000 0.0000 10.0000 0.0000 0.0000 2.0000 1.0000
0.0000 0.0000 0.0000 10.0000 0.0000 0.0000 2.0000 1.0000
11.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1.0000 100.0000
15.0000 0.0000 0.0000 -10.0000 0.0000 0.0000 2.0000 1.0000
27
-45.6243 -40.4815 42.0513 -0.8380 -6.3628 4.5484 12.0279 2.2721
8.7056 -9.8256 34.1560 6.0068 6.2527 -6.8506 28.9807 1.5037
30.1481 29.9591 -46.2881 6.7611 8.6669 1.5629 14.5578 1.3181
24.2927 8.3779 -21.8931 0.7074 0.1879 -8.9742 5.5877 2.6893
25.3009 -42.9168 10.7480 -7.2477 -8.5507 7.7846 13.7923 2.8726
17.6938 42.3577 -5.0334 6.4949 -2.1472 -5.3101 23.3066 1.4769
-7.9296 -29.6442 -24.2157 -1.1064 -9.5802 6.5858 12.4250 2.3816
9.5851 -20.0455 -35.1885 5.7477 -1.0622 2.5211 3.5233 1.2466
-35.5762 44.5412 -46.7816 3.6053 0.4991 4.3470 20.6922 2.8529
-44.9386 -48.0381 -43.6877 7.4101 3.9491 7.1619 10.4301 2.4920
-49.9870 -28.6276 -2.6522 5.8008 -1.0054 -4.9061 25.1188 1.4916
45.0228 
...(truncated)

Submitted solutions:

code_snippet: #include<iostream>
#include<vector>
#include<iomanip>
#include<cmath>
#include<algorithm>

using namespace std;
using P = pair<double, pair<int, int> >;

double p[200][3];
double v[200][3];
double r[200];
double rv[200];
double life[200];
bool die[200];
double tdie[200];

int n;

double coll_time(int i, int j) {
    double R = r[i] + r[j];
    double RV = rv[i] + rv[j];
    double ce2 = - RV * RV;
    double ce1 = 2 * R * RV;
    double ce0 = - R * R;

    for (int k = 0; k < 3; ++k) {
        double P = p[i][k] - p[j][k];
        double V = v[i][k] - v[j][k];
        ce2 += V * V;
        ce1 += 2 * P * V;
        ce0 += P * P;
    }

    double ans;
    if (ce2 != 0) {
        double D = ce1 * ce1 - 4 * ce0 * ce2;
        if (D < 0) return -1;
        ans = (- ce1 - sqrt(D)) / (2 * ce2);
    } else {
        ans = - ce0 / ce1;
    }
    if (ans < 0) return -1;
    return ans;
}

void solve() {
    vector<P> death;
    for (int i = 0; i < n; ++i) {
        cin >> p[i][0] >> p[i][1] >> p[i][2] >> v[i][0] >> v[i][1] >> v[i][2] >> r[i] >> rv[i];
        life[i] = r[i] / rv[i];
        death.push_back(make_pair(life[i], make_pair(i, -1)));
        die[i] = false;
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            double collt = coll_time(i, j);
            if (collt < 0) continue;
            death.push_back(make_pair(collt, make_pair(i, j)));
        }
    }

    sort(death.begin(), death.end());

    int cnt = 0;
    for (P d : death) {
        double t = d.first;
        int i = d.second.first;
        int j = d.second.second;

        //cout << t << ", " << i << ", " << j << endl;
        if (j == -1 && !die[i]) {
            die[i] = true;
            tdie[i] = t;
            cnt++;
        } else if (j != -1 && !die[i] && !die[j]) {
            die[i] = true;
            die[j] = true;
            tdie[i] = t;
            tdie[j] = t;
            cnt += 2;
        }
        if (cnt >= n) break;
    }

    for (int i = 0; i < n; ++i) {
        cout << fixed << setprecision(10) << tdie[i] << endl;
    }
}

int main() {
    while (cin >> n) {
        if (n == 0) return 0;
        //cout << "=============" << endl;
        solve();
    }
}
accuracy: 1
time_ms: 40
memory_kb: 4120
final_rank: 6

code_snippet: #ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
// #include <boost/rational.hpp>
// using namespace boost;
// using rat = rational<long long int>;
using mint = modint998244353;
// using mint = modint1000000007;
// using mint = mint;
using ll = long long;
using ld = long double;
using ull = uint64_t;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vm = vector<mint>;
using vvm = vector<vm>;
using vvvm = vector<vvm>;
using vstr = vector<string>;
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
#define vvvv(T) vector<vector<vector<vector<T>>>>

istream &operator>>(istream &is, mint &a){ll tmp; is >> tmp; a = tmp; return is;}
ostream &operator<<(ostream &os, const mint &a){ os << a.val(); return os; }
string to_string(const __int128_t &a) { if (a == 0) return "0"; string s = ""; __int128_t num = a; bool is_negative = false; if (num < 0) { is_negative = true; num = -num; } while (num > 0) { s += '0' + (num % 10); num /= 10; } if (is_negative) s += '-'; reverse(s.begin(), s.end()); return s; }
istream &operator>>(istream &is, __int128_t &a){ string s; is >> s; a = 0; for(char c : s) { if(isdigit(c)) {a = a*10 + (c - '0'); }  } if(s[0]=='-'){ a *= -1; } return is; }
ostream &operator<<(ostream &os, const __int128_t &a){ os << to_string(a); return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T> istream &operator>>(istream &is, vector<T> &vec){ for(T &e : vec){is >> e;} return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &vec) { for(int i = 0; i < (int)vec.size(); i++) { os << vec[i] << (i + 1 != (int)vec.size() ? " " : ""); } return os; }

template <class... T> constexpr auto min (T... a) { return min(initializer_list<common_type_t<T...>>{a...}); }
template <class... T> constexpr auto max (T... a) { return max(initializer_list<common_type_t<T...>>{a...}); }
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template<class T> T opmin(T x, T y) { return min(x, y); }
template<class T> T einf() { return numeric_limits<T>::max(); }
template<class T> T opmax(T x, T y) { return max(x, y); }
template<class T> T eminf() { return numeric_limits<T>::min(); }
template<class T> T opsum(T x, T y) { return x + y; }
template<class T> T ezero() { return (T)0; }
// #define maxseg(T) segtree<T, [](T x, T y){return max(x, y);}, [](){return (T)(-(1LL << 60));}>
// #define minseg(T) segtree<T, [](T x, T y){return min(x, y);}, [](){return (T)((1LL << 60));}>
// #define sumseg(T) segtree<T, [](T x, T y){return x + y;}, [](){return (T)(0);}>
template<class T> using minseg = segtree<T, opmin<T>, einf<T>>;
template<class T> using maxseg = segtree<T, opmax<T>, eminf<T>>;
template<class T> using sumseg = segtree<T, opsum<T>, ezero<T>>;
// template<class T> struct v : vector<T> { using vector<T> :: vector; };
// template<class T> struct vv : vector<v<T>> { using vector<v<T>> :: vector; };
// template<class T> struct vvv : vector<vv<T>> { using vector<vv<T>> :: vector; };
template<class T> inline bool chmin(T& a, T b) {if(a > b){a = b; return true;} else {return false;}};
template<class T> inline bool chmax(T& a, T b) {if(a < b){a = b; return true;} else {return false;}};
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i,n) for(ll i = (ll)(n) - 1; i >= 0; i--)
#define REP(i, l, r) for(ll i = (ll)l; i <= (ll)(r); i++)
#define REPR(i, l, r) for(ll i = (ll)r; i >= (ll)(l); i--)
const ll inf = (1 << 30);
const ll INF = (1LL << 60);
const vector<pair<ll, ll>> DIJ = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
void out(){cout<<'\n';}
template<class T, class... Ts> void out(const T& a, const Ts&... b){ cout<<a; (cout<<... << (cout << ' ', b)); cout << '\n';}
void outf(){cout<<endl;}
template<class T, class... Ts> void outf(const T& a, const Ts&... b){ cout<<a; (cout<<... << (cout << ' ', b)); cout << endl;}
template<class T, class U> void outp(pair<T, U> a){ out((a).first, (a).second); }
template<class T, class U> void outpf(pair<T, U> a){ outf((a).first, (a).second); }
template<class T> void outv(T a){rep(i, (a).size()){ cout << (a)[i] << " "; } cout << endl;}
template<class T> void outvL(T a){rep(i, (a).size()){out((a)[i]);} cout << flush; }
// template<class T> void outvv(T a){rep(i, a.size()){ rep(j, a.at(i).size()){cout << a.at(i).at(j) << " "; } cout << endl; }}
// template<class T> void outvp(T a){rep(i, a.size()){ out2(a.at(i).first, a.at(i).second); }}
void setpre(int a){cout << fixed << setprecision(a);}
#define outN out("No")
#define outY out("Yes")
#define outYN(flag) out(flag ? "Yes" : "No")
#define dame(...) {outf(__VA_ARGS__);return 0;}

template<class T> void read(vector<T>& vec){ for(int i = 0; i < (int)vec.size(); i++) { cin >> vec[i]; } }
template<class... T> void read(T&... a){(cin >> ... >> a);}
#define readll(...) ll __VA_ARGS__; read(__VA_ARGS__)
#define readvll(a, n) vector<ll> a(n); read(a)
#define readvt(type, a, n) vector<type> a(n); read(a)
#define readvll2(a, b, n) vector<ll> a(n), b(n); for(int lopi = 0; lopi < (int)(n); lopi++) cin >> (a)[lopi] >> (b)[lopi]
#define readvll3(a, b, c, n) vector<ll> a(n), b(n), c(n); for(int lopi = 0; lopi < (int)(n); lopi++) cin >> (a)[lopi] >> (b)[lopi] >> (c)[lopi]
#define readstr(...) string __VA_ARGS__; read(__VA_ARGS__)
#define readundirG(G, N, M) G = vvll(N); rep(lopi, M) {ll a, b; cin >> a >> b; G[a-1].push_back(b-1); G[b-1].push_back(a-1);}
#define readdirG(G, N, M) G = vvll(N); rep(lopi, M) {ll a, b; cin >> a >> b; G[a-1].push_back(b-1);}
#define readundirwghG(G, N, M) G = vv(pll)(N); rep(lopi, M) {ll a, b, c; cin >> a >> b >> c; G[a-1].emplace_back(b-1,c); G[b-1].emplace_back(a-1, c);}
#define readdirwghG (G, N, M) G = vv(pll)(N); rep(lopi, M) {ll a, b, c; cin >> a >> b >> c; G[a-1].emplace_back(b-1, c);}

#define All(a) (a).begin(), (a).end()
template<class T> inline void sortr(T& a){ sort((a).rbegin(), (a).rend()); }
template<class T> inline vector<int> argsort(T V, bool rev = false){vector<int> res(V.size()); iota(res.begin(), res.end(), 0); sort(res.begin(), res.end(), [&](int x, int y){if(!rev){return V[x] < V[y];}else{return V[x] > V[y];}}); return res;}
template<class T, class U> inline void sort_by_idx(T& V, vector<U>& I){assert(V.size() == I.size()); T tmpv = V; for(int loopi = 0; loopi < (int)I.size(); loopi++){V[loopi] = tmpv[I.at(loopi)];}}
template<class T, class U> inline void sortp(vector<T>& v1, vector<U>& v2, bool rev1 = false, int rev2 = false){assert(v1.size() == v2.size()); vector<int> I(v1.size()); iota(I.begin(), I.end(), 0); sort(I.begin(), I.end(), [&](const int x, const int y){if(v1[x] != v1[y]){return (bool)(rev1 ^ (v1[x] < v1[y]));}else{if(v2[x]==v2[y]){return false;} return (bool)(rev2 ^ (v2[x] < v2[y]));}}); sort_by_idx(v1, I); sort_by_idx(v2, I);}
template<class T> T POW(T x, ll n) {T ret = 1; while(n > 0){if(n & 1) ret *= x; x *= x; n >>= 1;} return ret;}
ll powll(ll x, ll n){ll ret = 1; while(n > 0){if(n & 1) ret *= x; x *= x; n >>= 1;} return ret;}
inline ll divceil(ll x, ll y) { if(x >= 0) {return(x / y + (ll)(x % y != 0)); } else { return -((-x) / y); } }
inline ll divfloor(ll x, ll y) { if(x >= 0) { return x/y; } else { return -((-x)/y + (ll)((-x) % y != 0)); } }
inline bool inLR(ll x, ll L, ll R){ return (L <= x && x < R); }
inline bool inRect(ll pos_x, ll pos_y, ll rect_H, ll rect_W, ll rect_h = 0, ll rect_w = 0){ return (rect_h <= pos_x && pos_x < rect_H && rect_w <= pos_y && pos_y < rect_W); }

template<class T> vector<T> &operator++(vector<T> &v) {for(auto &e : v){e++;} return v;}
template<class T> vector<T> operator++(vector<T> &v, signed) {auto res=v; for(auto &e : v){e++;} return res;}
template<class T> vector<T> &operator--(vector<T> &v) {for(auto &e : v){e--;} return v;}
template<class T> vector<T> operator--(vector<T> &v, signed) {auto res=v; for(auto &e : v){e--;} return res;}
template<class T> vector<T> operator+(const vector<T> &x, const vector<T> &y) { assert(x.size() == y.size()); vector<T> ret(x.size()); for(int i = 0; i < (int)x.size(); i++) {ret[i] = x[i] + y[i];} return ret; }
template<class T> vector<T> operator-(const vector<T> &x, const vector<T> &y) { assert(x.size() == y.size()); vector<T> ret(x.size()); for(int i = 0; i < (int)x.size(); i++) {ret[i] = x[i] - y[i];} return ret; } 

template<class T, class U> pair<T, U> operator+(const pair<T, U> &x, const pair<T, U> &y) { return make_pair(x.first + y.first, x.second + y.second); }
template<class T, class U> pair<T, U> operator-(const pair<T, U> &x, const pair<T, U> &y) { return make_pair(x.first - y.first, x.second - y.second); }
template<class T, class U> void operator+=(pair<T, U> &x, pair<T, U> &y) { x = x + y; }
template<class T, class U> void operator-=(pair<T, U> &x, pair<T, U> &y) { x = x - y; }

template<class T> size_t HashCombine(const size_t seed,const T &v){ return seed^(std::hash<T>()(v)+0x9e3779b9+(seed<<6)+(seed>>2)); }
template<class T,class S> struct std::hash<std::pair<T,S>>{ size_t operator()(const std::pair<T,S> &keyval) const noexcept { return HashCombine(std::hash<T>()(keyval.first), keyval.second); } };
template<class T> struct std::hash<std::vector<T>>{ size_t operator()(const std::vector<T> &keyval) const noexcept { size_t s=0; for (auto&& v: keyval) s=HashCombine(s,v); return s; } };
template<int N> struct HashTupleCore{ template<class Tuple> size_t operator()(const Tuple &keyval) const noexcept{ size_t s=HashTupleCore<N-1>()(keyval); return HashCombine(s,std::get<N-1>(keyval)); } };
template <> struct HashTupleCore<0>{ template<class Tuple> size_t operator()(const Tuple &keyval) const noexcept{ return 0; } };
template<class... Args> struct std::hash<std::tuple<Args...>>{ size_t operator()(const tuple<Args...> &keyval) const noexcept { return HashTupleCore<tuple_size<tuple<Args...>>::value>()(keyval); } };

const ld eps = 1e-14;

int main()
{
    std::cin.tie(nullptr), std::ios_base::sync_with_stdio(false);
    setpre(20);
    while(true)
    {
        readll(N);
        if(!N) break;
        v(ld) px(N), py(N), pz(N), vxi(N), vyi(N), vzi(N), ri(N), vri(N);
        rep(i, N)
        {
            read(px[i], py[i], pz[i], vxi[i], vyi[i], vzi[i], ri[i], vri[i]);
        }
        vector<set<pair<ld, ll>>> S(N);
        rep(i, N)
        {
            S[i].insert({ri[i]/vri[i], i});
        }
        rep(i, N - 1) REP(j, i + 1, N - 1)
        {
            ld x = px[i] - px[j], y = py[i] - py[j], z = pz[i] - pz[j];
            ld vx = vxi[i] - vxi[j], vy = vyi[i] - vyi[j], vz = vzi[i] - vzi[j];
            ld r = ri[i] + ri[j], vr = vri[i] + vri[j];
            ld a = vx*vx + vy*vy + vz*vz - vr*vr;
            ld b = x*vx + y*vy + z*vz + r*vr;
            ld c = x*x + y*y + z*z - r*r;
            if(a < 0)
            {
                a = -a;
                b = -b;
                c = -c;
            }
            ld mxt = min(ri[i]/vri[i], ri[j]/vri[j]) + eps;
            if(abs(a) < eps)
            {
                if(abs(b) < eps)
                {
                    if(abs(c) < eps)
                    {
                        S[i].insert({0.0, j});
                        S[j].insert({0.0, i});
                    }
                }
                else
                {
                    ld t = -c/(2*b);
                    if(0 <= t && t <= mxt)
                    {
                        S[i].insert({t, j});
                        S[j].insert({t, i});
                        // if(i == 1 && j == 5) out(t, "a");
                    }
                }
            }
            else
            {
                if(b*b - a*c >= 0.0)
                {
                    ld t1 = (-b + sqrtl(b*b - a*c))/a;
                    ld t2 = (-b - sqrtl(b*b - a*c))/a;
                    if(t1 > t2) swap(t1, t2);
                    if(0 <= t1 && t1 <= mxt)
                    {
                        S[i].insert({t1, j});
                        S[j].insert({t1, i});
                        // if(i == 1 && j == 5) out(t1, t2, "b");
                    }
                    else if(0 <= t2 && t2 <= mxt)
                    {
                        S[i].insert({t2, j});
                        S[j].insert({t2, i});
                        // if(i == 1 && j == 5) out(t2, t1, "c");
                    }
                }
            }
        }
        v(ld) ans(N, INF);
        ll cnt = N;
        while(cnt > 0)
        {
            ll mi;
            pair<ld, ll> mn = {INF, INF};
            rep(i, N)
            {
                if(ans[i] < INF || S[i].empty()) continue;
                if(chmin(mn, *S[i].begin())) mi = i;
            }
            auto [t, mj] = mn;
            // out(mi, mj, t);
            ans[mi] = t;
            cnt--;
            vll er = {mi};
            if(mi == mj) S[mi].erase(mn);
            if(mi != mj && S[mj].find({t, mi}) == S[mj].begin())
            {
                ans[mj] = t;
                cnt--;
                er.emplace_back(mj);
            }
            for(auto e : er)
            {
                for(auto [tt, jj] : S[e])
                {
                    if(e == jj) continue;
                    S[jj].erase({tt, e});
                }
                S[e].clear();
            }
        }
        outvL(ans);
    }
}
accuracy: 1
time_ms: 20
memory_kb: 4096
final_rank: 5

code_snippet: # include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double pi = acos(-1);
template<class T>constexpr T inf() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T hinf() { return inf<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); }
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); }
template<class T> bool chmin(T& a,T b) { if(a > b){a = b; return true;} return false; }
template<class T> bool chmax(T& a,T b) { if(a < b){a = b; return true;} return false; }
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(ll n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(ll n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a%b); };
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g*b; };
ll MOD(ll x, ll m){return (x%m+m)%m; }
ll FLOOR(ll x, ll m) {ll r = (x%m+m)%m; return (x-r)/m; }
template<class T> using dijk = priority_queue<T, vector<T>, greater<T>>;
# define all(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(all((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(all((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(all((rprpr)),(rprpr).begin(),TU<char>)
# define rep(i,upupu)         for(ll i = 0, i##_len = (upupu);(i) < (i##_len);(i)++)
# define reps(i,opopo)        for(ll i = 1, i##_len = (opopo);(i) <= (i##_len);(i)++)
# define len(x)                ((ll)(x).size())
# define bit(n)               (1LL << (n))
# define pb push_back
# define eb emplace_back
# define exists(c, e)         ((c).find(e) != (c).end())

struct INIT{
	INIT(){
		std::ios::sync_with_stdio(false);
		std::cin.tie(0);
		cout << fixed << setprecision(20);
	}
}INIT;

namespace mmrz {
	void solve();
}

int main(){
	mmrz::solve();
}
#define debug(...) (static_cast<void>(0))

using namespace mmrz;

using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using ull = unsigned long long;
using lll = __int128;
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=a;i<n;++i)
#define per2(i,a,n) for (ll i=a;i>=n;--i)

// [BEGIN] template の include

constexpr double EPS = 1e-9;

//a > 0ならば+1, a == 0ならば0, a < 0ならば-1　を返す。　基本的にEPS込みの評価はこれで行う。
//不等式は、加減算に直してこれに適用する。
int sgn(const double a) {
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}

int SOLVE(){
	int n;
	cin >> n;
	if(n == 0)return 1;
	vector px(n, 0.0), py(n, 0.0), pz(n, 0.0);
	vector vx(n, 0.0), vy(n, 0.0), vz(n, 0.0);

	vector R(n, 0.0), vr(n, 0.0);

	rep(i, n){
		cin >> px[i] >> py[i] >> pz[i];
		cin >> vx[i] >> vy[i] >> vz[i];
		cin >> R[i] >> vr[i];
	}

	vector<double> ans(n);
	rep(i, n)ans[i] = R[i]/vr[i];

	auto f = [&](int i, int j, double t) -> double {
		double ix = px[i] + vx[i]*t, iy = py[i] + vy[i]*t, iz = pz[i] + vz[i]*t;
		double jx = px[j] + vx[j]*t, jy = py[j] + vy[j]*t, jz = pz[j] + vz[j]*t;
		
		double dist = sqrtl((ix-jx)*(ix-jx) + (iy-jy)*(iy-jy) + (iz-jz)*(iz-jz));
		
		dist -= R[i]-vr[i]*t;
		dist -= R[j]-vr[j]*t;

		return dist;
	};

	vector intersect_time(n, vector(n, hinf<double>()));
	rep(i, n)for(int j = i+1;j < n;j++){
		//debug("cross", i, j);
		double lo = 0.0, hi = min(ans[i], ans[j]);
		rep(_, 100){
			double c1 = (lo+lo+hi) / 3.0;
			double c2 = (lo+hi+hi) / 3.0;
			//debug(lo, hi, c1, c2, f(i, j, c1), f(i, j, c2));
			if(f(i, j, c1) > f(i, j, c2)){
				lo = c1;
			}else{
				hi = c2;
			}
		}
		if(sgn(f(i, j, lo)) == 1)continue;
		//debug("time", i, j);
		double l = 0.0, r = lo;
		rep(_, 100){
			double mid = (l+r)/2.0;
			if(sgn(f(i, j, mid)) == 1)l = mid;
			else r = mid;
		}
		if(sgn(ans[i]-r) == -1)continue;
		if(sgn(ans[j]-r) == -1)continue;
		intersect_time[i][j] = r;
		//debug(r);
	}

	//debug("end");

	vector<tuple<double, int, int>> tij;
	rep(i, n)for(int j = i+1;j < n;j++){
		if(intersect_time[i][j] == hinf<double>())continue;
		tij.eb(intersect_time[i][j], i, j);
	}

	//debug(tij);

	sort(all(tij));
	vector<bool> flg(n, false);
	for(auto [t, i, j] : tij){
		if(flg[i])continue;
		if(flg[j])continue;
		flg[i] = true;
		flg[j] = true;
		ans[i] = t;
		ans[j] = t;
	}
	rep(i, n){
		cout << ans[i] << '\n';
	}
	return 0;
}

void mmrz::solve(){
	while(!SOLVE());
}
accuracy: 1
time_ms: 1330
memory_kb: 4168
final_rank: 17

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

struct Vect {
    double X, Y, Z;
    Vect(double x, double y, double z) : X(x), Y(y), Z(z) {};
};

double Norm(Vect V) {
    return V.X*V.X+V.Y*V.Y+V.Z*V.Z;
}

double Dot(Vect V1, Vect V2) {
    return V1.X*V2.X + V1.Y*V2.Y + V1.Z*V2.Z;
}

Vect operator+(Vect V1, Vect V2) {
    return Vect(V1.X+V2.X,V1.Y+V2.Y,V1.Z+V2.Z);
}

Vect operator-(Vect V1, Vect V2) {
    return Vect(V1.X-V2.X,V1.Y-V2.Y,V1.Z-V2.Z);
}

struct Star {
    Vect P, V;
    double R, VR;
    Star(Vect p, Vect v, double r, double vr) : P(p), V(v), R(r), VR(vr) {};
};

double eps = 1e-6;

double HitTime(Star S1, Star S2) {
    Vect P = S2.P-S1.P, V = S2.V-S1.V;
    double R = S1.R+S2.R, VR = S1.VR+S2.VR;
    double A = Norm(V) - VR*VR;
    double B = 2.0 * Dot(P,V) + 2.0 * R * VR;
    double C = Norm(P) - R*R;
    if (A <= eps) return -1.0;
    if (B*B-4.0*A*C <= eps) return -1.0;
    double X = (-B - sqrt(B*B-4.0*A*C))/(2.0*A);
    if (0.0 <= X && X <= R/VR) return X;
    X = (-B + sqrt(B*B-4.0*A*C))/(2.0*A);
    if (0.0 <= X && X <= R/VR) return X;
    return -1.0;
}

int main() {
while(1){
    int N;
    cin >> N;
    if (N == 0) return 0;
    vector<Star> S;
    rep(i,0,N) {
        double X1, Y1, Z1, X2, Y2, Z2, R, VR;
        cin >> X1 >> Y1 >> Z1 >> X2 >> Y2 >> Z2 >> R >> VR;
        S.push_back(Star(Vect(X1,Y1,Z1),Vect(X2,Y2,Z2),R,VR));
    }
    vector<vector<double>> Hit(N,vector<double>(N,-1.0));
    rep(i,0,N) {
        rep(j,0,N) {
            if (i == j) continue;
            Hit[i][j] = HitTime(S[i],S[j]);
        }
    }
    vector<pair<double,pair<int,int>>> Event;
    rep(i,0,N) Event.push_back({S[i].R/S[i].VR,{i,i}});
    rep(i,0,N) {
        rep(j,i+1,N) {
            if (Hit[i][j] >= 0) Event.push_back({Hit[i][j],{i,j}});
        }
    }
    sort(ALL(Event));
    vector<bool> Vanished(N,false);
    vector<double> ANS(N);
    for (auto P : Event) {
        double T = P.first, ID1 = P.second.first, ID2 = P.second.second;
        if (Vanished[ID1] || Vanished[ID2]) continue;
        ANS[ID1] = ANS[ID2] = T;
        Vanished[ID1] = Vanished[ID2] = true;
    }
    rep(i,0,N) {
        printf("%.12f\n",ANS[i]);
    }
}
}
accuracy: 1
time_ms: 30
memory_kb: 3668
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define all(A) A.begin(),A.end()
template <class T>
void chmax(T& p, T q) { p = max(p, q); };
template <class T>
bool chmin(T& p, T q) {
    if (p > q) {
        p = min(p, q);
        return 1;
    }
    return 0;
};


const double EPS = 1e-12;
void solve(ll N) {
    vector<bool> seen(N, 1);

    vector<vector<double>> X(N, vector<double>(3));
    auto V = X;
    vector<double> R(N), VR(N);
    rep(i, N)cin >> X[i][0] >> X[i][1] >> X[i][2] >> V[i][0] >> V[i][1] >> V[i][2] >> R[i] >> VR[i];
    vector<pair<double, pair<ll, ll>>> EV;
    rep(i, N) {
        EV.push_back({ R[i] / VR[i],{i,-1} });
    }
    rep(i, N)rep(j, i) {
        vector<double> F(3, 0);
        vector<double> DX(3, 0), DV(3, 0);
        rep(k, 3)DX[k] = X[i][k] - X[j][k];
        rep(k, 3)DV[k] = V[i][k] - V[j][k];
        rep(k, 3)F[2] += DV[k] * DV[k];
        rep(k, 3)F[1] += DV[k] * DX[k] * 2.0;
        rep(k, 3)F[0] += DX[k] * DX[k];
        double DR = R[i] + R[j];
        double DVR = VR[i] + VR[j];
        F[2] -= DVR * DVR;
        F[1] += 2.0 * DVR * DR;
        F[0] -= DR * DR;

        if (abs(F[2]) < EPS) {
            if (abs(F[1] < EPS))continue;
            double t = -F[0] / F[1];
            if(t>0.0)EV.push_back({ t,{i,j} });
        }
        else {
            F[1] /= F[2];
            F[0] /= F[2];

            double Q = F[1] * F[1] - 4.0 * F[0];
            if (Q < 0)continue;
            Q = sqrt(Q);
            double a = (-F[1] + Q) / 2.0;
            double b = (-F[1] - Q) / 2.0;
            if (b > 0.0) {
                EV.push_back({ b,{i,j} });
            }
            else if (a > 0.0) {
                EV.push_back({ a,{i,j} });

            }
        }
    }
    sort(all(EV));
    vector<double> AN(N);
    for (auto tvw : EV) {
        double t = tvw.first;
        ll v = tvw.second.first;
        ll w = tvw.second.second;
        if (w == -1) {
            if (seen[v]) {
                seen[v] = 0;
                AN[v] = t;
            }
            continue;
        }
        if (seen[v] && seen[w]) {
            seen[v] = 0;
            seen[w] = 0;
            AN[v] = t;
            AN[w] = t;
        }
    }
    cout<<fixed<<setprecision(15);
    rep(i, N)cout << AN[i] << "\n";
};


int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);



    ll N;
    while (cin >> N) {
        if (N == 0)return 0;
        solve(N);
    }



}
accuracy: 1
time_ms: 50
memory_kb: 4656
final_rank: 13

code_snippet: #include <bits/stdc++.h>

using R = long double;
const R EPS{1e-12};

struct Point {
    R x, y, z;
    Point() = default;
    Point(R x, R y, R z) : x{x}, y{y}, z{z} {}
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x >> p.y >> p.z;
        return is;
    }
    friend Point operator+(const Point& p, const Point& q) {
        return Point{p.x + q.x, p.y + q.y, p.z + q.z};
    }
    friend Point operator-(const Point& p, const Point& q) {
        return Point{p.x - q.x, p.y - q.y, p.z - q.z};
    }
    friend Point operator*(const Point& p, R t) {
        return Point{p.x * t, p.y * t, p.z * t};
    }
};

bool Positive(R v) {
    return v > EPS;
}

bool Negative(R v) {
    return v < -EPS;
}

bool Zero(R v) {
    return std::abs(v) < EPS;
}

bool Exist(R A, R B, R C) {
    return B * B - 4 * A * C >= -EPS;
}

std::pair<bool, R> Equation(R A, R B, R C) {
    if (!Exist(A, B, C)) {
        return { false, 0.0l };
    }
    R pm{sqrtl(B * B - 4 * A * C)};
    R l{(-B + pm) / (2 * A)}, r{(-B - pm) / (2 * A)};
    if (Negative(A)) {
        if (Negative(std::max(l, r))) {
            assert(false);
            return { false, 0.0l };
        }
        else if (Negative(std::min(l, r))) {
            return { true, std::max(l, r) };
        }
        else {
            assert(false);
            return { false, 0.0l };
        }
    }
    else {
        if (Negative(std::max(l, r))) {
            return { false, 0.0l };
        }
        else if (Positive(std::min(l, r))) {
            return { true, std::min(l, r) };
        }
        else {
            assert(false);
            return { false, 0.0l };
        }
    }
}

std::pair<bool, R> OneEquation(R A, R B) { // at + b = 0
    if (Zero(A)) return { false, 0.0l };
    if (Negative(-B / A)) return { false, 0.0l };
    return { true, -B / A };
}

R Square(R v) {
    return v * v;
}

bool solve() {
    int N;
    std::cin >> N;
    if (N == 0) return false;
    std::vector<Point> P(N), V(N);    
    std::vector<R> rad(N), vrad(N);
    for (int i{} ; i < N ; i++) {
        std::cin >> P[i] >> V[i] >> rad[i] >> vrad[i];
    }

    auto calc{[&](int i, int j) -> std::pair<bool, R> {
        R leftX2{Square(V[i].x - V[j].x)};
        R leftX1{2 * (V[i].x - V[j].x) * (P[i].x - P[j].x)};
        R leftX0{Square(P[i].x - P[j].x)};
        R leftY2{Square(V[i].y - V[j].y)};
        R leftY1{2 * (V[i].y - V[j].y) * (P[i].y - P[j].y)};
        R leftY0{Square(P[i].y - P[j].y)};
        R leftZ2{Square(V[i].z - V[j].z)};
        R leftZ1{2 * (V[i].z - V[j].z) * (P[i].z - P[j].z)};
        R leftZ0{Square(P[i].z - P[j].z)};
        R left2{leftX2 + leftY2 + leftZ2}, left1{leftX1 + leftY1 + leftZ1}, left0{leftX0 + leftY0 + leftZ0};
        R right2{Square(vrad[i] + vrad[j])};
        R right1{-2 * (rad[i] + rad[j]) * (vrad[i] + vrad[j])};
        R right0{Square(rad[i] + rad[j])};

        R A{left2 - right2}, B{left1 - right1}, C{left0 - right0};
        if (Zero(A)) {
            return OneEquation(B, C);
        }
        else {
            return Equation(A, B, C);
        }
    }};
    
    
    std::vector<std::tuple<R, int, int>> erase;
    erase.reserve(N * N + N);
    for (int i{} ; i < N ; i++) {
        R t{rad[i] / vrad[i]};
        erase.emplace_back(t, i, -1);
    }
    for (int i{} ; i < N ; i++) {
        for (int j{i + 1} ; j < N ; j++) {
            auto [f, t]{calc(i, j)};
            if (!f) continue;
            erase.emplace_back(t, i, j);
        }
    }
    std::sort(erase.begin(), erase.end());
    std::vector<bool> used(N);
    std::vector<R> ans(N);
    for (auto [t, i, j] : erase) {
        if (j == -1) {
            if (used[i]) continue;
            used[i] = true;
            ans[i] = t;
        }
        else {
            if (used[i] or used[j]) continue;
            used[i] = used[j] = true;
            ans[i] = ans[j] = t;
        }
    }
    std::cout << std::fixed << std::setprecision(10);
    for (auto a : ans) {
        std::cout << a << '\n';
    }
    return true;
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
    
    while (solve()) ;
}
accuracy: 1
time_ms: 40
memory_kb: 4196
final_rank: 9

code_snippet: #include <bits/stdc++.h>

using Real = long double;
constexpr Real EPS = 1e-10;
constexpr Real NONE = 1e18;
constexpr int LOOP = 50;

int sign(Real x) {
    return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

bool eq(Real lhs, Real rhs) {
    return sign(rhs - lhs) == 0;
}

bool lte(Real lhs, Real rhs) {
    return sign(rhs - lhs) >= 0;
}

bool lt(Real lhs, Real rhs) {
    return sign(rhs - lhs) > 0;
}

bool gte(Real lhs, Real rhs) {
    return lte(rhs, lhs);
}

bool gt(Real lhs, Real rhs) {
    return lt(rhs, lhs);
}

struct Point {
    explicit Point(Real x = 0, Real y = 0, Real z = 0): x(x), y(y), z(z) {}
    Real x, y, z;
    friend Point operator+(Point lhs, Point rhs) {
        return Point(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
    }
    friend Point operator*(Point lhs, Real k) {
        return Point(lhs.x * k, lhs.y * k, lhs.z * k);
    }
    friend Point operator-(Point lhs, Point rhs) {
        return Point(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
    }
};

Real norm(Point p) {
    return p.x * p.x + p.y * p.y + p.z * p.z;
}

using Vector = Point;

struct Star {
    Point v;
    Vector dv;
    Real r;
    Real dr;
    Star() {}

    //  r - dr * t = 0
    //  t = r / dr;
    Real finish_time() {
        return r / dr;
    }
    Point pos(Real t) {
        // assert(lte(0, t) && lte(t, finish_time()));
        return v + (dv * t);
    }
    Real rad(Real t) {
        // assert(lte(0, t) && lte(t, finish_time()));
        return r - dr * t;
    }
};

//  二点間距離が最小となる時間を返す
//  存在しないならばNONE
Real intersect(Star lhs, Star rhs) {
    Real l = 0;
    Real r = std::min(lhs.finish_time(), rhs.finish_time());
    for (int loop = 0; loop < LOOP; loop++) {
        Real m[2] = {(2 * l + r) / 3, (l + 2 * r) / 3};
        Real d[2];
        for (int i = 0; i < 2; i++) {
            Point a = lhs.pos(m[i]);
            Point b = rhs.pos(m[i]);
            Real p = norm(a - b);
            Real q = lhs.rad(m[i]) + rhs.rad(m[i]);
            d[i] = p - q * q;
        }
        if (lt(d[0], d[1])) {
            r = m[1];
        } else {
            l = m[0];
        }
    }
    Point a = lhs.pos(l);
    Point b = rhs.pos(l);
    Real p = norm(a - b);
    Real q = lhs.rad(l) + rhs.rad(l);
    Real d = p - q * q;
    if (lte(d, 0)) return l;
    return NONE;
}

//  [0, t]は単調減少
Real impact(Star lhs, Star rhs, Real tmax) {
    Real l = 0;
    Real r = tmax;
    for (int loop = 0; loop < LOOP; loop++) {
        Real m = (l + r) / 2;
        Point a = lhs.pos(m);
        Point b = rhs.pos(m);
        Real p = norm(a - b);
        Real q = lhs.rad(m) + rhs.rad(m);
        Real d = p - q * q;
        if (lt(d, 0)) {
            r = m;
        } else {
            l = m;
        }
    }
    return l;
}

std::istream& operator>>(std::istream& is, Star& star) {
    Point v;
    Vector dv;
    Real r;
    Real dr;
    is >> v.x >> v.y >> v.z;
    is >> dv.x >> dv.y >> dv.z;
    is >> r >> dr;
    star.v = v;
    star.dv = dv;
    star.r = r;
    star.dr = dr;
    return is;
}

int solve() {
    int n;
    std::cin >> n;
    if (n == 0) return 1;
    std::vector<Star> stars(n);
    for (int i = 0; i < n; i++) std::cin >> stars[i];

    std::vector<Real> ans(n, NONE);

    //  (time, type, lhs, rhs)
    //  type = 1 => 消滅
    //  type = 2 => 衝突
    using Event = std::tuple<Real, int, int, int>;
    std::vector<Event> events;
    for (int i = 0; i < n; i++) {
        events.emplace_back(stars[i].finish_time(), 1, i, -1);
        for (int j = i + 1; j < n; j++) {
            Real s = intersect(stars[i], stars[j]);
            if (s == NONE) continue;
            Real t = impact(stars[i], stars[j], s);
            events.emplace_back(t, 2, i, j);
        }
    }
    std::sort(events.begin(), events.end());

    for (auto [t, q, x, y]: events) {
        if (q == 1) {
            if (ans[x] == NONE) {
                ans[x] = t;
            }
        } else {
            if (ans[x] == NONE && ans[y] == NONE) {
                ans[x] = ans[y] = t;
            }
        }
    }

    std::cout << std::fixed << std::setprecision(10);
    for (int i = 0; i < n; i++) {
        std::cout << ans[i] << '\n';
    }

    return 0;
}

int main() {
    while (!solve());
}
accuracy: 1
time_ms: 600
memory_kb: 3584
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
using Real = long double;
const Real EPS = 1e-8;
inline int sign(const Real& r) {
    if(r <= -EPS) return -1;
    if(r >= +EPS) return +1;
    return 0;
}
inline bool eq(const Real& a, const Real& b) {
    return sign(a - b) == 0;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(30);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        vector<Real> px(n), py(n), pz(n), vx(n), vy(n), vz(n), r(n), vr(n);
        rep(i, 0, n) {
            cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
        }
        vector<vector<Real>> time(n, vector<Real>(n, -1));
        rep(i, 0, n) {
            rep(j, i + 1, n) {
                Real dpx = px[i] - px[j], dpy = py[i] - py[j], dpz = pz[i] - pz[j];
                Real dvx = vx[i] - vx[j], dvy = vy[i] - vy[j], dvz = vz[i] - vz[j];
                Real sr = r[i] + r[j];
                Real svr = vr[i] + vr[j];
                Real a = dvx * dvx + dvy * dvy + dvz * dvz - svr * svr;
                Real b = 2 * (dpx * dvx + dpy * dvy + dpz * dvz + svr * sr);
                Real c = dpx * dpx + dpy * dpy + dpz * dpz - sr * sr;
                if(sign(a) <= 0) continue;
                Real D = b * b - 4 * a * c;
                if(D < 0) continue;
                Real cand = (-b - sqrt(D)) / (2 * a);
                if(cand < 0 or cand > r[i] / vr[i] or cand > r[j] / vr[j]) continue;
                time[i][j] = cand;
            }
        }
        vector<pair<Real, P>> vec;
        rep(i, 0, n) {
            vec.push_back({r[i] / vr[i], P(i, i)});
            rep(j, i + 1, n) {
                if(time[i][j] == -1) continue;
                vec.push_back({time[i][j], P(i, j)});
            }
        }
        sort(vec.begin(), vec.end());
        vector<bool> flag(n, false);
        vector<Real> ans(n);
        rep(i, 0, (int)vec.size()) {
            Real t = vec[i].first;
            int idx1 = vec[i].second.first, idx2 = vec[i].second.second;
            if(!flag[idx1] and !flag[idx2]) {
                ans[idx1] = t;
                ans[idx2] = t;
                flag[idx1] = true;
                flag[idx2] = true;
            }
        }
        rep(i, 0, n) {
            cout << ans[i] << '\n';
        }
    }
}
accuracy: 1
time_ms: 20
memory_kb: 4180
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
using Real = long double;
const Real EPS = 1e-8;
inline int sign(const Real& r) {
    if(r <= -EPS) return -1;
    if(r >= +EPS) return +1;
    return 0;
}
inline bool eq(const Real& a, const Real& b) {
    return sign(a - b) == 0;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(30);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        vector<Real> px(n), py(n), pz(n), vx(n), vy(n), vz(n), r(n), vr(n);
        rep(i, 0, n) {
            cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
        }
        vector<vector<Real>> time(n, vector<Real>(n, -1));
        rep(i, 0, n) {
            rep(j, i + 1, n) {
                Real dpx = px[i] - px[j], dpy = py[i] - py[j], dpz = pz[i] - pz[j];
                Real dvx = vx[i] - vx[j], dvy = vy[i] - vy[j], dvz = vz[i] - vz[j];
                Real sr = r[i] + r[j];
                Real svr = vr[i] + vr[j];
                Real a = dvx * dvx + dvy * dvy + dvz * dvz - svr * svr;
                Real b = 2 * (dpx * dvx + dpy * dvy + dpz * dvz + svr * sr);
                Real c = dpx * dpx + dpy * dpy + dpz * dpz - sr * sr;
                if(sign(a) <= 0) continue;
                Real D = b * b - 4 * a * c;
                if(D < 0) continue;
                Real cand = (-b - sqrt(D)) / (2 * a);
                if(cand < 0 or cand > r[i] / vr[i] or cand > r[j] / vr[j]) continue;
                time[i][j] = cand;
            }
        }
        vector<pair<Real, P>> vec;
        rep(i, 0, n) {
            vec.push_back({r[i] / vr[i], P(i, i)});
            rep(j, i + 1, n) {
                if(time[i][j] == -1) continue;
                vec.push_back({time[i][j], P(i, j)});
            }
        }
        sort(vec.begin(), vec.end());
        vector<bool> flag(n, false);
        vector<Real> ans(n);
        rep(i, 0, (int)vec.size()) {
            Real t = vec[i].first;
            int idx1 = vec[i].second.first, idx2 = vec[i].second.second;
            if(!flag[idx1] and !flag[idx2]) {
                ans[idx1] = t;
                ans[idx2] = t;
                flag[idx1] = true;
                flag[idx2] = true;
            }
        }
        rep(i, 0, n) {
            cout << ans[i] << '\n';
        }
    }
}
accuracy: 1
time_ms: 20
memory_kb: 4160
final_rank: 7

code_snippet: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, s, n) for (int i = int(s); i < int(n); i++)
#define rrep(i, s, n) for (int i = int(n) - 1; i >= int(s); i--)
#define all(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using ld = long double;

template <class T> bool chmin(T &a, T b) {
    if (a <= b) return false;
    a = b;
    return true;
}

template <class T> bool chmax(T &a, T b) {
    if (a >= b) return false;
    a = b;
    return true;
}

using namespace std;

struct vec{
    ld x, y, z;
    vec (ld _x = 0, ld _y = 0, ld _z = 0) : x(_x), y(_y), z(_z){}
    vec& operator*=(const ld& a){
        x *= a; y *= a; z *= a;
        return *this;
    }
    vec& operator/=(const ld& a){
        x /= a; y /= a; z /= a;
        return *this;
    }
    vec& operator+=(const vec& rhs){
        x += rhs.x;
        y += rhs.y;
        z += rhs.z;
        return *this;
    }
    vec& operator-=(const vec& rhs){
        x -= rhs.x;
        y -= rhs.y;
        z -= rhs.z;
        return *this;
    }
    friend vec operator+(const vec& lhs, const vec& rhs){
        return vec(lhs) += rhs;
    }
    friend vec operator-(const vec& lhs, const vec& rhs){
        return vec(lhs) -= rhs;
    }
    friend vec operator*(const vec& lhs, const ld& rhs){
        return vec(lhs) *= rhs;
    }
    friend vec operator*(const ld& rhs, const vec& lhs){
        return vec(lhs) *= rhs;
    }
    friend vec operator/(const vec& lhs, const ll& rhs){
        return vec(lhs) /= rhs;
    }
    friend std::ostream &operator<<(std::ostream &os, const vec &r){
        return os << "(" << r.x << "," << r.y << "," << r.z << ")";
    }
};

bool operator==(const vec& lhs, const vec& rhs){
    return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z;
}
ld dot(const vec &a, const vec &b){
    return a.x*b.x + a.y*b.y + a.z*b.z;
}
vec cross(const vec &a, const vec &b){
    return vec(a.y*b.z - a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y - a.y*b.x);
}
ld norm(const vec&a){
    return a.x*a.x + a.y*a.y + a.z*a.z;
}

int sgn(ld a, ld eps = 1e-9){
    return (a < -eps) ? -1 : (a > eps) ? 1 : 0;
}

void solve(int n){
    vector<vec> xs(n), vs(n);
    vector<ld> rs(n), ks(n);
    rep(i,0,n){
        ld x, y, z; cin >> x >> y >> z;
        ld vx, vy, vz; cin >> vx >> vy >> vz;
        xs[i] = vec(x,y,z);
        vs[i] = vec(vx,vy,vz);
        cin >> rs[i] >> ks[i];
    }
    using P = pair<int,int>;
    vector<pair<ld,P>> tms;
    rep(i,0,n){
        tms.emplace_back(rs[i]/ks[i],P(i,i));
    }
    rep(i,0,n-1) rep(j,i+1,n){ //cout << i << j << endl;
        vec dx = xs[i] - xs[j];
        vec dv = vs[i] - vs[j]; //cout << dx << dv << endl;
        ld dr = rs[i] + rs[j];
        ld dk = ks[i] + ks[j];
        ld a = dk*dk - norm(dv);
        ld b = -2*dr*dk - 2*dot(dx,dv);
        ld c = dr*dr - norm(dx);
        assert(sgn(c) < 0);
        if (sgn(a) == 1){
            ld t = (-b+sqrtl(b*b-4*a*c)) / (2*a);
            if (sgn(rs[i] - ks[i]*t) == 1 && sgn(rs[j] - ks[j]*t) == 1){
                tms.emplace_back(t,P(i,j));
            }
        }
        else if (sgn(a) == -1){ //cout << a << " " << b << " " << c << endl;
            if (sgn(b*b-4*a*c) < 0) continue;
            ld t = (-b+sqrtl(b*b-4*a*c)) / (2*a); //cout << t << endl;
            if (sgn(t) == -1) continue;
            if (sgn(rs[i] - ks[i]*t) == 1 && sgn(rs[j] - ks[j]*t) == 1){
                tms.emplace_back(t,P(i,j));
            }
        }
        else {
            if (sgn(b) <= 0) continue;
            ld t = -c/b;
            if (sgn(rs[i] - ks[i]*t) == 1 && sgn(rs[j] - ks[j]*t) == 1){
                tms.emplace_back(t,P(i,j));
            }   
        }
    }
    sort(all(tms));
    const ld dinf = 1e9;
    vector<ld> ans(n,dinf);
    for (auto [t, p] : tms){ //cout << t << endl;
        auto [i, j] = p;
        if (sgn(ans[i]-dinf) >= 0 && sgn(ans[j]-dinf) >= 0){
            ans[i] = t;
            ans[j] = t;
            continue;
        }
    }
    rep(i,0,n) cout << ans[i] << endl;
}

int main() {
    cout << fixed << setprecision(15);
    while (true){
        int n; cin >> n;
        if (n == 0) break;
        solve(n);
    }
}
accuracy: 1
time_ms: 30
memory_kb: 3716
final_rank: 3

code_snippet: #include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using lint = ll;
using ulint = ull;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
#define For(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) For(i, 0, n)
template <class T, class U>
bool chmin(T &a, const U &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T, class U>
bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
ostream &operator<<(ostream &os, const V<T> &v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

#include <cmath>
#include <tuple>
using re = long double;
re EPS = 1e-11;

int sgn(re x) {
    if (x < -EPS) return -1;
    if (x > EPS) return 1;
    return 0;
}
bool eq(re x, re y) { return sgn(x - y) == 0; }
bool ge(re x, re y) { return sgn(x - y) == 1; }
bool le(re x, re y) { return sgn(x - y) == -1; }
bool geq(re x, re y) { return sgn(x - y) >= 0; }
bool leq(re x, re y) { return sgn(x - y) <= 0; }

re solve(re a, re b, re c) {
    if (le(a, 0)) {
        a = -a;
        b = -b;
        c = -c;
    }

    if (eq(a, 0)) {
        return -c / b;
    }

    auto d = b * b - 4 * a * c;
    if (le(d, 0)) return -1;

    auto t = (-b - sqrt(d)) / (2 * a);
    if (geq(t, 0)) return t;

    t = (-b + sqrt(d)) / (2 * a);
    return t;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;

        V<re> x(n), y(n), z(n), vx(n), vy(n), vz(n), r(n), vr(n);
        rep(i, n) {
            cin >> x[i] >> y[i] >> z[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >>
                vr[i];
        }

        V<tuple<re, int, int>> events;
        rep(i, n) { events.emplace_back(r[i] / vr[i], i, -1); }

        rep(i, n) For(j, i + 1, n) {
            auto dx = x[i] - x[j];
            auto dvx = vx[i] - vx[j];

            auto dy = y[i] - y[j];
            auto dvy = vy[i] - vy[j];

            auto dz = z[i] - z[j];
            auto dvz = vz[i] - vz[j];

            auto ar = r[i] + r[j];
            auto avr = vr[i] + vr[j];

            re a = dvx * dvx + dvy * dvy + dvz * dvz - avr * avr;
            re b = 2 * dx * dvx + 2 * dy * dvy + 2 * dz * dvz + 2 * ar * avr;
            re c = dx * dx + dy * dy + dz * dz - ar * ar;

            // cout << a << " " << b << " " << c << endl;

            auto t = solve(a, b, c);

            // cout << t << endl;

            if (t < 0) continue;

            events.emplace_back(t, i, j);
        }

        sort(events.begin(), events.end());

        V<re> ans(n);
        V<bool> used(n, false);
        for (auto [t, i, j] : events) {
            if (j < 0) {
                if (used[i]) continue;
                ans[i] = t;
                used[i] = true;
            } else {
                if (used[i] || used[j]) continue;
                ans[i] = ans[j] = t;
                used[i] = used[j] = true;
            }
        }
        for (auto x : ans) printf("%.15Lf\n", x);
    }
}
accuracy: 1
time_ms: 50
memory_kb: 4896
final_rank: 15

code_snippet: #ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, l, r) for(int i = int(l); i < int(r); i++)
#define rep(i, n)    rng(i, 0, n)
#define SZ(v)        int(v.size())
#define foa(s, v)    for(auto &s : v)
#define all(v)       v.begin(), v.end()

template <class T>
using V = vector<T>;

using pii = pair<int, int>;

using ld = long double;

struct comet {
	array<ld, 3> start_p;
	array<ld, 3> speed;
	ld r, vr, end_time;
	comet() = default;
	comet(ld sx_, ld sy_, ld sz_, ld vx_, ld vy_, ld vz_, ld r_, ld vr_) : r(r_), vr(vr_), end_time(r_ / vr_) {
		start_p = {sx_, sy_, sz_};
		speed = {vx_, vy_, vz_};
	}
	array<ld, 3> get_pos(ld now_time) const {
		array<ld, 3> ret;
		rep(i, 3) {
			ret[i] = start_p[i] + speed[i] * now_time;
		}
		return ret;
	}
	ld get_rad(ld now_time) const {
		return r - vr * now_time;
	}
};

int n;
void solve() {
	vector<comet> comets(n);
	rep(i, n) {
		ld a, b, c, d, e, f, g, h;
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
		comets[i] = comet(a, b, c, d, e, f, g, h);
	}
	vector<pair<ld, pii>> events;
	vector<ld> ans(n + 1);
	// event_sort {time, pair}
	rep(i, n) {
		const auto &A = comets[i];
		events.push_back(pair(A.end_time, pair(i, n)));
		rng(j, i + 1, n) {
			const auto &B = comets[j];
			auto fin = min(A.end_time, B.end_time);
			auto get_cent_dist = [&](ld now_time) {
				auto ap = A.get_pos(now_time);
				auto bp = B.get_pos(now_time);
				ld dist = 0;
				rep(k, 3) dist += (ap[k] - bp[k]) * (ap[k] - bp[k]);
				return sqrt(dist);
			};
			// sqrt(at^2+bt+c) + dt - e <= 0 なる最小の t を求める　-> 凸性　最小値が求まる -> 最小値の位置からにぶたん？

			auto get_sur_dist = [&](ld now_time) {
				auto cent_dist = get_cent_dist(now_time);
				auto ra = A.get_rad(now_time);
				auto rb = B.get_rad(now_time);
				return cent_dist - ra - rb;
			};


			// 3 個の軸でいつ入れ替わるか調査
			// a+bt = c+dt
			//(b-d)t = c-a
			// t = (c-a)/(b-d)
			V<ld> times{0, fin};
			rep(k, 3) {
				auto a = A.start_p[k];
				auto b = A.speed[k];
				auto c = B.start_p[k];
				auto d = B.speed[k];
				auto nt = (c - a) / (b - d);
				if(nt > 0 and nt < fin) times.push_back(nt);
			}

			sort(all(times));

			rep(k, SZ(times)) {
				if(i == 1 and j == 4) {
				}
			}
			ld col_time = -1;
			rep(k, SZ(times) - 1) {
				auto st = times[k];
				auto gt = times[k + 1];
				ld lef = st, rig = gt;
				rep(_, 50) {
					ld c1 = lef + (rig - lef) / 3;
					ld c2 = rig - (rig - lef) / 3;
					if(get_sur_dist(c1) > get_sur_dist(c2))
						lef = c1;
					else
						rig = c2;
				}
				auto ok = (lef + rig) / 2;
				if(get_sur_dist(ok) > 0) continue;
				auto ng = st;
				rep(_, 50) {
					auto mid = (ok + ng) / 2;
					if(get_sur_dist(mid) <= 0)
						ok = mid;
					else
						ng = mid;
				}
				col_time = ok;
				break;
			}


			if(col_time >= 0) {
				events.push_back(pair(col_time, pair(i, j)));
			}
		}
	}
	sort(all(events));
	vector<int> fin(n + 1);
	for(auto [t, p] : events) {
		auto [x, y] = p;
		if(fin[x] or fin[y]) continue;
		fin[x] = 1;
		if(y < n) fin[y] = 1;
		ans[x] = ans[y] = t;
	}
	ans.pop_back();
	rep(i, n) cout << ans[i] << endl;
}

int main() {
	cout << fixed << setprecision(15);
	while(cin >> n && n) solve();
}
accuracy: 1
time_ms: 1060
memory_kb: 3636
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ld = long double;
using point = tuple<ld, ld, ld>;

point operator-(const point& a, const point& b) {
    return point{
        get<0>(a) - get<0>(b),
        get<1>(a) - get<1>(b),
        get<2>(a) - get<2>(b),
    };
}

ld distance(const point& a, const point& b) {
    auto [dx, dy, dz] = a - b;
    return sqrtl(dx * dx + dy * dy + dz * dz);
}

struct star {
    ld px, py, pz, r;
    ld vx, vy, vz, vr;
    star() : px{}, py{}, pz{}, r{}, vx{}, vy{}, vz{}, vr{} {}
    star(ld px_, ld py_, ld pz_, ld r_, ld vx_, ld vy_, ld vz_, ld vr_) 
        : px{ px_ }, py{ py_ }, pz{ pz_ }, r{ r_ }, vx{ vx_ }, vy{ vy_ }, vz{ vz_ }, vr{ vr_ } {}

    point pos(ld t = 0.0l) const {
        return point{
            px + t * vx,
            py + t * vy,
            pz + t * vz,
        };
    }

    ld radius(ld t = 0.0l) const {
        return r - t * vr;
    }

    bool disap(ld t = 0.0l) const {
        return radius(t) < 0;
    }

    ld disaptime() const {
        return r / vr;
    }
};

ld distance(const star& A, const star& B, ld time) {
    point tA = A.pos(time), tB = B.pos(time);
    ld dist = distance(tA, tB);
    assert(!A.disap(time) and !B.disap(time));
    ld value = dist - A.radius(time) - B.radius(time);
    return value;
}

ld intersect(const star& A, const star& B, ld time) {
    return distance(A, B, time) <= 0.0l;
}

const int search_time = 50;

ld getR(const star& A, const star& B) {
    ld L = 0.0, R = min(A.disaptime(), B.disaptime());
    for (int _ = 0 ; _ < search_time ; _++) {
        ld M1 = (2 * L + R) / 3, M2 = (L + 2 * R) / 3;
        ld M1v = distance(A, B, M1), M2v = distance(A, B, M2);
        if (M1v < M2v) {
            R = M2;
        }
        else {
            L = M1;
        }
    }

    ld res = (L + R) / 2;
    if (!intersect(A, B, res)) return -1.0l;
    else return res;
}

ld collision(const star& A, const star& B) {
    ld R = getR(A, B);
    if (R < 0.0l) return -1.0l;
    ld L = 0.0l;
    for (int _ = 0 ; _ < search_time ; _++) {
        ld M = (L + R) / 2;
        (intersect(A, B, M) ? R : L) = M;
    }
    return R;
}

vector<ld> solve(int N) {
    vector<star> S(N);
    for (int i = 0 ; i < N ; i++) {
        ld px, py, pz, vx, vy, vz, r, vr;
        cin >> px >> py >> pz >> vx >> vy >> vz >> r >> vr;
        S[i] = star{ px, py, pz, r, vx, vy, vz, vr };
    }


    using tup = tuple<ld, int, int>;
    vector<tup> T{};
    for (int i = 0 ; i < N ; i++) {
        for (int j = i + 1 ; j < N ; j++) {
            ld time = collision(S[i], S[j]);
            if (time > 0.0l) T.emplace_back(time, i, j);
        }
    }

    sort(T.begin(), T.end());
    vector used(N, false);

    vector<ld> res(N, -1.0l);
    
    for (auto [time, a, b] : T) {
        if (used[a] or used[b]) continue;
        res[a] = time;
        res[b] = time;
        used[a] = used[b] = true;
    }

    for (int i = 0 ; i < N ; i++) if (res[i] < 0) {
        res[i] = S[i].disaptime();
        assert(res[i] > 0.0l);
    }

    return res;
}

int main() {
    cout << fixed << setprecision(10);
    while (1) {
        int N; cin >> N;
        if (N == 0) break;
        auto ans = solve(N);
        for (auto v : ans) cout << v << endl; 
    } 
}
accuracy: 1
time_ms: 1070
memory_kb: 3600
final_rank: 10

code_snippet: #include<bits/stdc++.h>

using namespace std;

class Point{
  public:
    double x;
    double y;
    double z;
    Point(double x,double y,double z):x(x),y(y),z(z){}
    Point():Point(0,0,0){}
};

Point operator+(Point a,Point b){
  return Point(a.x+b.x,a.y+b.y,a.z+b.z);
}

Point operator-(Point a,Point b){
  return Point(a.x-b.x,a.y-b.y,a.z-b.z);
}

Point operator*(Point a,double b){
  return Point(a.x*b,a.y*b,a.z*b);
}

double abs(Point a){
  return sqrt(a.x*a.x+a.y*a.y+a.z*a.z);
}

Point input(){
  Point x;
  cin >> x.x >> x.y >> x.z;
  return x;
}

vector<double> func(int n){
  vector<Point> ps(n);
  vector<Point> vs(n);
  vector<double> rs(n);
  vector<double> rss(n);
  for(int i=0;i<n;++i){
    ps[i] = input();
    vs[i] = input();
    cin >> rs[i];
    cin >> rss[i];
  }

  using T = tuple<double,int,int>;
  vector<T> events;
  for(int i=0;i<n;++i){
    events.emplace_back(rs[i]/rss[i],i,i);
  }

  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      Point p1 = ps[i];
      Point p2 = ps[j];
      Point v1 = vs[i];
      Point v2 = vs[j];
      double r1 = rs[i];
      double r2 = rs[j];
      double rs1 = rss[i];
      double rs2 = rss[j];
      auto dist = [&](double t){
        Point P1 = p1 + v1 * t;
        Point P2 = p2 + v2 * t;
        return abs(P1 - P2) - r1 - r2 + rs1 * t + rs2 * t;
      };
      double lp = 0;
      double rp = 1e9;
      for(int _=0;_<100;++_){
        double mid1 = (lp + lp + rp) / 3;
        double mid2 = (lp + rp + rp) / 3;
        if(dist(mid1) < dist(mid2)){
          rp = mid2;
        }else{
          lp = mid1;
        }
      }
      lp = 0;
      for(int _=0;_<100;++_){
        double mid = (lp + rp) / 2;
        if(dist(mid) < 0){
          rp = mid;
        }else{
          lp = mid;
        }
      }
      double t = lp;
      if(abs(dist(t)) < 1e-9){
        events.emplace_back(t,i,j);
      }
    }
  }

  vector<double> res(n,-1);
  sort(events.begin(),events.end());
  for(auto i:events){
    double t = get<0>(i);
    int a = get<1>(i);
    int b = get<2>(i);
    if(res[a] >= 0 or res[b] >= 0)continue;
    res[a] = res[b] = t;
  }
  return res;
}

int main(){
  int n;
  while(cin >> n && n){
    for(auto i:func(n)){
      printf("%.20lf\n",i);
    }
  }
}
accuracy: 1
time_ms: 2170
memory_kb: 3632
final_rank: 16

code_snippet: #include<bits/stdc++.h>
#define rep(i, N) for(int i = 0; i < N; i++)

using namespace std;
using ll = long long;
using ld = long double;

const ld EPS = 1e-14;
const ll LINF = 2e18;

ld pw2(ld x){ return x * x; }

struct Point{
    ld x, y, z;
    ld vx, vy, vz;
    ld r, vr;
};
istream& operator>>(istream& is, Point& P){
    is >> P.x >> P.y >> P.z;
    is >> P.vx >> P.vy >> P.vz;
    is >> P.r >> P.vr;
    return is;
}
ld dist2(Point A, Point B, ld t){
    ld X = A.x + A.vx * t - (B.x + B.vx * t);
    ld Y = A.y + A.vy * t - (B.y + B.vy * t);
    ld Z = A.z + A.vz * t - (B.z + B.vz * t);

    ld val = pw2(X) + pw2(Y) + pw2(Z);
    ld val2 = (A.r - A.vr * t) +  (B.r - B.vr * t);
    return val - val2 * val2;
}
ld solve(Point A, Point B){
    ld L = 0, R = min(A.r / A.vr, B.r / B.vr);
    while(R - L > EPS){
        ld mid1 = (L + L + R) / 3, mid2 = (L + R + R) / 3;
        ld val1 = dist2(A, B, mid1);
        ld val2 = dist2(A, B, mid2);
        if(val1 < val2) R = mid2;
        else L = mid1;
    }
    if(dist2(A, B, L) > 0) return LINF;

    R = L;
    L = 0;
    while(R - L > EPS){
        ld mid = (L + R) / 2;
        if(dist2(A, B, mid) >= 0) L = mid;
        else R = mid;
    }
    return L;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    while(1){
        int N; cin >> N;
        if(N == 0) break;
        vector<Point> pts(N);
        rep(i, N) cin >> pts[i];

        vector<ld> ans(N);
        rep(i, N){
            auto p = pts[i];
            //cout << p.x << p.y << p.z << p.vx << p.vy << p.vz << p.r << p.vr << endl;
            ans[i] = p.r / p.vr;
        }

        vector<vector<ld>> dist(N, vector<ld>(N));
        rep(i, N){
            rep(j, N){
                if(i == j) continue;
                dist[i][j] = solve(pts[i], pts[j]);
            }
        }

        vector<bool> used(N);
        rep(i, N){
            int a = -1, b = -1;
            ld mn = LINF / 2;
            rep(j, N){
                if(used[j]) continue;
                for(int k = j + 1; k < N; k++){
                    if(used[k]) continue;
                    if(mn > dist[j][k]){
                        mn = dist[j][k];
                        a = j, b = k;
                    }
                }
            }
            if(a == -1) break;
            used[a] = used[b] = 1;
            ans[a] = ans[b] = mn;
        }

        rep(i, N){
            cout << ans[i] << '\n';
        }
    }
    return 0;
}
accuracy: 1
time_ms: 3030
memory_kb: 4168
final_rank: 19

code_snippet: #include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <random>
#include <complex>
#include <bitset>
#include <iomanip>
#include <memory>
#include <functional>
#include <stack>
#include <limits>

#define rep(i, n, s) for (int i = (s); i < int(n); i++)
#define per(i, n, s) for (int i = (n) - 1; i >= int(s); i--)
#define MM << " " <<
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using MaxHeap = std::priority_queue<T>;

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;
using Pdd = std::pair<double, double>;

template <class T>
bool chmin(T &a, const T b) {
    if (b < a) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
bool chmax(T &a, const T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void vdeb(const std::vector<T> &da) {
    auto n = da.size();
    for (size_t i = 0; i < n; i++) {
        if (i == n - 1)
            std::cout << da[i];
        else
            std::cout << da[i] << " ";
    }
    std::cout << std::endl;
}
template<class T>
void vdeb(const std::vector<std::vector<T>> &da) {
    auto n = da.size();
    for (size_t i = 0; i < n; i++) {
        std::cout << i << " : ";
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

using Real = long double;

int n;
const Real nil = -(1e20);
const Real EPS = 1e-12;
const Real infi = 1e10;

struct Para {
    ll coeff[3];
    Para() {
        fill(all(coeff), 0.0);
    }
    Real solve() const {
        // cerr << coeff[0] MM coeff[1] MM coeff[2] << endl;
        if(abs(coeff[2]) == 0) {
            if(abs(coeff[1]) == 0) return nil;
            else return (Real) -coeff[0] / coeff[1];
        } else {
            __int128_t a(coeff[2]), b(coeff[1]), c(coeff[0]);
            if(b*b - a * c * 4 < 0) return nil;
            else {
                // Real x = -100000;
                // rep(i,50,0) x += (x*x*coeff[2] + x*coeff[1] + coeff[0]) / (2 * coeff[2] * x + coeff[1]);
                // return x;
                Real tmp = (-coeff[1] - sqrt((Real)coeff[1] * coeff[1] - (Real)coeff[2] * coeff[0] * 4.0)) / (coeff[2] * 2);
                // cerr << "!" MM tmp << endl;
                return tmp;
            }
        }
    }
};

Para add(const Para &x, const Para& y) {
    Para ret;
    rep(i,3,0) ret.coeff[i] = x.coeff[i] + y.coeff[i];
    return ret;
}

Para myminus(const Para &x, const Para& y) {
    Para ret;
    rep(i,3,0) ret.coeff[i] = x.coeff[i] - y.coeff[i];
    return ret;
}

Para times(const Para &x, const Para& y) {
    Para ret;
    rep(i,3,0) {
        rep(j,i+1,0) ret.coeff[i] += x.coeff[j] * y.coeff[i-j];
    }
    return ret;
}

struct Star {
    vector<Para> p;
    Para r;
    Star() : p(3), r() {}
};

double judge(const Star &x, const Star &y) {
    Star z;
    Para f;
    rep(i,3,0) {
        z.p[i] = myminus(x.p[i], y.p[i]);
        z.p[i] = times(z.p[i], z.p[i]);
        f = add(f, z.p[i]);
        // rep(j,3,0) {
            // cerr<< x.p[i].coeff[j] MM y.p[i].coeff[j]  << endl;
        // }
    }
    {
        z.r = add(x.r, y.r);
        f = myminus(f, times(z.r, z.r));
        // cerr<< z.r.coeff[2] << endl;
    }
    return f.solve();
}

ll normalize(Real x) {
    if(x >= 0.0) return ll(x * 100000 + 1) / 10;
    else return ll(x * 100000 - 1) / 10;
}

void solve() {
    vector<Star> da(n);
    rep(i,n,0) {
        rep(j,2,0) rep(k,3,0) {
            Real x; cin >> x;
            da[i].p[k].coeff[j] = normalize(x);
        }
        rep(j,2,0) {
            Real x; cin >> x;
            da[i].r.coeff[j] = normalize(x);
        }
        da[i].r.coeff[1] *= -1;
    }
    vector<pair<Real, Pii>> event;
    rep(i,n,0) {
        event.emplace_back(da[i].r.solve(), make_pair(i, -1));
    }
    rep(i,n,0) rep(j,i,0) {
        auto now = judge(da[i], da[j]);
        if(now < 0.0) continue;
        event.emplace_back(now, make_pair(i, j));
    }
    sort(all(event));
    vector<Real> ans(n, infi);
    for(auto &i : event) {
        // cerr << i.first MM i.second.first MM i.second.second << endl;
        if(i.second.second == -1) {
            chmin(ans[i.second.first], i.first);
        } else {
            if(ans[i.second.first] == infi && ans[i.second.second] == infi) {
                ans[i.second.first] = i.first;
                ans[i.second.second] = i.first;
            }
        }
    }
    for(auto &i : ans) cout << i << endl;
}

int main() {
    cout << setprecision(10) << fixed;
    while(1) {
        cin >> n;
        if(n == 0) break;
        solve();
    }
}
accuracy: 1
time_ms: 90
memory_kb: 4856
final_rank: 14

code_snippet: #line 1 "d.cpp"
/*	author:  Kite_kuma
	created: 2022.07.02 13:48:51 */

#line 2 "SPJ-Library/template/kuma.hpp"

#line 2 "SPJ-Library/template/basic_func.hpp"

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

template <class T0, class T1, class T2>
inline bool in_range(T0 x, T1 lef, T2 rig) {
	return ((lef <= x) && (x < rig));
}

template <class T>
inline bool chmin(T &a, T b) {
	if(a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b) {
	if(a < b) {
		a = b;
		return true;
	}
	return false;
}

void Yes(bool flag = true) { std::cout << (flag ? "Yes" : "No") << '\n'; }
void YES(bool flag = true) { std::cout << (flag ? "YES" : "NO") << '\n'; }

template <class T>
void drop(T answer) {
	std::cout << answer << '\n';
	exit(0);
}

template <class T>
void vout(std::vector<T> const &v, bool vertically = 0) {
	if(vertically) {
		for(auto const &a : v) {
			std::cout << a << '\n';
		}
		return;
	}
	for(auto it = v.begin(); it != v.end(); it++) {
		std::cout << (*it);
		if(it != v.end() - 1) {
			std::cout << ' ';
		}
	}
	std::cout << '\n';
	return;
}

inline void print() { std::cout << '\n'; }
template <class T>
inline void print(const T &x) {
	std::cout << x << '\n';
	return;
}
template <typename Head, typename... Tail>
void print(const Head &H, const Tail &... T) {
	std::cout << H << " ";
	print(T...);
}

template <class T>
void add(std::vector<T> &v, T value) {
	for(auto &a : v) a += value;
	return;
}

template <class T>
T greatest_lower_multiple(T x, T d) {
	if(d == 0) return 0;
	if(d < 0) d *= -1;
	T y = x % d;
	if(y < 0) y += d;
	return x - y;
}

template <class T>
T least_upper_multiple(T x, T d) {
	return -greatest_lower_multiple(-x, d);
}

// ceil(a / b);
template <class T>
T dup(T a, T b) {
	assert(b);
	if(b < 0) {
		a *= -1;
		b *= -1;
	}
	return least_upper_multiple(a, b) / b;
}

long long pow_ll(long long a, long long n) {
	assert(n >= 0LL);
	if(n == 0) return 1LL;
	if(a == 0) return 0LL;
	if(a == 1) return 1LL;
	if(a == -1) return (n & 1LL) ? -1LL : 1LL;
	long long res = 1;
	while(n > 1LL) {
		if(n & 1LL) res *= a;
		a *= a;
		n >>= 1;
	}
	return res * a;
}

long long modpow(long long a, long long n, long long mod) {	 // a^n mod
	assert(n >= 0 && mod);
	if(mod == 1) return 0LL;
	long long res = 1;
	a %= mod;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res < 0 ? res + mod : res;
}

// return x which satisfies a * x % mod == gcd(a, mod)
// not (mod | a)
long long modinv(long long a, const long long mod) {
	long long b = mod, u = 1, v = 0;
	while(b) {
		long long t = a / b;
		a -= t * b;
		std::swap(a, b);
		u -= t * v;
		std::swap(u, v);
	}
	u %= mod;
	if(u < 0) u += mod;
	return u;
}

template <class T>
int lb(const std::vector<T> &a, const T x) {
	return (int)std::distance(a.begin(), std::lower_bound(a.begin(), a.end(), x));
}
template <class T>
int ub(const std::vector<T> &a, const T x) {
	return (int)std::distance(a.begin(), std::upper_bound(a.begin(), a.end(), x));
}
template <class T>
void unq_sort(std::vector<T> &a) {
	std::sort(a.begin(), a.end());
	a.erase(std::unique(a.begin(), a.end()), a.end());
}
template <class T>
std::vector<int> press(const std::vector<T> &a) {
	std::vector<T> vec = a;
	unq_sort(vec);
	std::vector<int> ret;
	for(const auto &v : a) ret.push_back(lb(vec, v));
	return ret;
}
#line 1 "SPJ-Library/template/header.hpp"
#include <bits/stdc++.h>
#line 2 "SPJ-Library/template/io.hpp"

#line 4 "SPJ-Library/template/io.hpp"

#line 8 "SPJ-Library/template/debug.hpp"

#line 3 "SPJ-Library/template/constants.hpp"

constexpr int inf = 1000'000'000;
constexpr long long INF = 1'000'000'000'000'000'000LL;
constexpr int mod_1000000007 = 1000000007;
constexpr int mod_998244353 = 998244353;
const long double pi = acosl(-1.);
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#line 10 "SPJ-Library/template/debug.hpp"

namespace viewer {

template <typename T, typename U>
void view(const std::pair<T, U> &p);

template <class T0, class T1, class T2>
void view(const std::tuple<T0, T1, T2> &p);

template <class T0, class T1, class T2, class T3>
void view(const std::tuple<T0, T1, T2, T3> &p);

void view(const long long &e);

void view(const int &e);

template <typename T>
void view(const T &e);

template <typename T>
void view(const std::set<T> &s);

template <typename T>
void view(const std::unordered_set<T> &s);

template <typename T>
void view(const std::multiset<T> &s);

template <typename T>
void view(const std::unordered_multiset<T> &s);

template <typename T>
void view(const std::vector<T> &v);

template <typename T, std::size_t ary_size>
void view(const std::array<T, ary_size> &v);

template <typename T>
void view(const std::vector<std::vector<T>> &vv);

template <typename T, typename U>
void view(const std::vector<std::pair<T, U>> &v);

template <class T0, class T1, class T2>
void view(const std::vector<std::tuple<T0, T1, T2>> &v);

template <class T0, class T1, class T2, class T3>
void view(const std::vector<std::tuple<T0, T1, T2, T3>> &v);

template <typename map_type>
void view_map_container(const map_type &m);

template <typename T, typename U>
void view(const std::map<T, U> &m);

template <typename T, typename U>
void view(const std::unordered_map<T, U> &m);

template <typename container_type>
void view_container(const container_type &c, bool vertically = false) {
	typename container_type::const_iterator begin = c.begin();
	const typename container_type::const_iterator end = c.end();
	if(vertically) {
		std::cerr << "{\n";
		while(begin != end) {
			std::cerr << '\t';
			view(*(begin++));
			if(begin != end) std::cerr << ',';
			std::cerr << '\n';
		}
		std::cerr << '}';
		return;
	}
	std::cerr << "{ ";
	while(begin != end) {
		view(*(begin++));
		if(begin != end) std::cerr << ',';
		std::cerr << ' ';
	}
	std::cerr << '}';
}

template <typename T, typename U>
void view(const std::pair<T, U> &p) {
	std::cerr << '(';
	view(p.first);
	std::cerr << ", ";
	view(p.second);
	std::cerr << ')';
}

template <class T0, class T1, class T2>
void view(const std::tuple<T0, T1, T2> &p) {
	std::cerr << '(';
	view(std::get<0>(p));
	std::cerr << ", ";
	view(std::get<1>(p));
	std::cerr << ", ";
	view(std::get<2>(p));
	std::cerr << ')';
}

template <class T0, class T1, class T2, class T3>
void view(const std::tuple<T0, T1, T2, T3> &p) {
	std::cerr << '(';
	view(std::get<0>(p));
	std::cerr << ", ";
	view(std::get<1>(p));
	std::cerr << ", ";
	view(std::get<2>(p));
	std::cerr << ", ";
	view(std::get<3>(p));
	std::cerr << ')';
}

void view(const long long &e) {
	if(e == INF)
		std::cerr << "INF";
	else if(e == -INF)
		std::cerr << "-INF";
	else
		std::cerr << e;
}

void view(const int &e) {
	if(e == inf)
		std::cerr << "inf";
	else if(e == -inf)
		std::cerr << "-inf";
	else
		std::cerr << e;
}

template <typename T>
void view(const T &e) {
	std::cerr << e;
}

template <typename T>
void view(const std::set<T> &s) {
	view_container(s);
}

template <typename T>
void view(const std::unordered_set<T> &s) {
	view_container(s);
}

template <typename T>
void view(const std::multiset<T> &s) {
	view_container(s);
}

template <typename T>
void view(const std::unordered_multiset<T> &s) {
	view_container(s);
}

template <typename T>
void view(const std::vector<T> &v) {
	view_container(v);
}

template <typename T, std::size_t ary_size>
void view(const std::array<T, ary_size> &v) {
	view_container(v);
}

template <typename T>
void view(const std::vector<std::vector<T>> &vv) {
	view_container(vv, true);
}

template <typename T, typename U>
void view(const std::vector<std::pair<T, U>> &v) {
	view_container(v, true);
}

template <class T0, class T1, class T2>
void view(const std::vector<std::tuple<T0, T1, T2>> &v) {
	view_container(v, true);
}

template <class T0, class T1, class T2, class T3>
void view(const std::vector<std::tuple<T0, T1, T2, T3>> &v) {
	view_container(v, true);
}

template <typename map_type>
void view_map_container(const map_type &m) {
	std::cerr << "{\n";
	for(typename map_type::const_iterator it = m.begin(); it != m.end(); it++) {
		std::cerr << "\t[";
		view(it->first);
		std::cerr << "] : ";
		view(it->second);
		std::cerr << '\n';
	}
	std::cerr << "}";
}

template <typename T, typename U>
void view(const std::map<T, U> &m) {
	view_map_container(m);
}

template <typename T, typename U>
void view(const std::unordered_map<T, U> &m) {
	view_map_container(m);
}

}  // namespace viewer

// when compiling : g++ foo.cpp -DLOCAL
#ifdef LOCAL
void debug_out() {}
template <typename T>
void debug_out(const T &x) {
	viewer::view(x);
}
template <typename Head, typename... Tail>
void debug_out(const Head &H, const Tail &... T) {
	viewer::view(H);
	std::cerr << ", ";
	debug_out(T...);
}
#define debug(...)                                                \
	do {                                                          \
		std::cerr << __LINE__ << " [" << #__VA_ARGS__ << "] : ["; \
		debug_out(__VA_ARGS__);                                   \
		std::cerr << "]\n";                                       \
	} while(0)
#else
#define debug(...) (void(0))
#endif
#line 2 "SPJ-Library/template/scanner.hpp"

#line 6 "SPJ-Library/template/scanner.hpp"

namespace scanner {
template <class T>
void scan(T &a) {
	std::cin >> a;
}

template <class T, class L>
void scan(std::pair<T, L> &p) {
	scan(p.first);
	scan(p.second);
}

template <class T0, class T1, class T2>
void scan(std::tuple<T0, T1, T2> &p) {
	T0 t0;
	T1 t1;
	T2 t2;
	scan(t0);
	scan(t1);
	scan(t2);
	p = std::make_tuple(t0, t1, t2);
}

template <class T0, class T1, class T2, class T3>
void scan(std::tuple<T0, T1, T2, T3> &p) {
	T0 t0;
	T1 t1;
	T2 t2;
	T3 t3;
	scan(t0);
	scan(t1);
	scan(t2);
	scan(t3);
	p = std::make_tuple(t0, t1, t2, t3);
}

template <class T>
void scan(std::vector<T> &a) {
	for(auto &i : a) scan(i);
}

void INPUT() {}
template <class Head, class... Tail>
void INPUT(Head &head, Tail &... tail) {
	scan(head);
	INPUT(tail...);
}
}  // namespace scanner
#line 7 "SPJ-Library/template/io.hpp"

#define VEC(type, name, size) \
	vector<type> name(size);  \
	scanner::INPUT(name)
#define VVEC(type, name, h, w)                     \
	vector<vector<type>> name(h, vector<type>(w)); \
	scanner::INPUT(name)
#define INT(...)     \
	int __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LL(...)            \
	long long __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define STR(...)        \
	string __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define CHR(...)      \
	char __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define DBL(...)        \
	double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LD(...)              \
	long double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define TPL3(type0, type1, type2, name)   \
	std::tuple<type0, type1, type2> name; \
	scanner::INPUT(name);
#define TPL4(type0, type1, type2, type3, name)   \
	std::tuple<type0, type1, type2, type3> name; \
	scanner::INPUT(name);

template <typename T1, typename T2>
std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return is;
}

template <typename T1, typename T2>
std::ostream &std::operator<<(std::ostream &os, const std::pair<T1, T2> &p) {
	os << p.first << ' ' << p.second;
	return os;
}
template <class T>
std::ostream &std::operator<<(std::ostream &os, const std::vector<T> &v) {
	for(typename std::vector<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if(it != v.begin()) std::cerr << ' ';
		os << *it;
	}
	return os;
}

struct fast_io {
	fast_io() {
		std::ios::sync_with_stdio(false);
		std::cin.tie(nullptr);
		std::cout << std::fixed << std::setprecision(15);
		srand((unsigned)time(NULL));
	}
} fast_io_;
#line 2 "SPJ-Library/template/macros.hpp"

#define foa(s, v) for(auto &s : v)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pcnt(n) __builtin_popcountll((long long)n)

#define REPname(a, b, c, d, e, ...) e
#define rep(...) REPname(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define REP0(x) for(int Counter_in_rep_macro = 0; Counter_in_rep_macro < (x); ++Counter_in_rep_macro)
#define REP1(i, x) for(int i = 0; i < (x); ++i)
#define REP2(i, l, r) for(int i = (l); i < (r); ++i)
#define REP3(i, l, r, c) for(int i = (l); i < (r); i += (c))
#define DREPname(a, b, c, d, e, ...) e
#define drep(...) DREPname(__VA_ARGS__, DREP3, DREP2, DREP1)(__VA_ARGS__)
#define DREP1(i, x) for(int i = (x)-1; i >= 0; --i)
#define DREP2(i, l, r) for(int i = (r)-1; i >= (l); --i)
#define DREP3(i, l, r, c) for(int i = (r)-1; i >= (l); i -= (c))

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vvvi = std::vector<std::vector<std::vector<int>>>;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
template <class T = ll>
using V = std::vector<T>;
template <class T = ll>
using VV = V<V<T>>;
template <class T = ll>
using VVV = V<V<V<T>>>;
template <class T = ll>
using pqup = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T = ll>
using pqdn = std::priority_queue<T>;
#line 7 "SPJ-Library/template/kuma.hpp"

using namespace std;
#line 5 "d.cpp"

// #include "SPJ-Library/geometry/geometry.hpp"

using R = long double;
using point = array<R, 3>;

point add(point a, point b) {
	point ret;
	rep(i, 3) ret[i] = a[i] + b[i];
	return ret;
}

point mult(point a, R value) {
	point ret;
	rep(i, 3) ret[i] = a[i] * value;
	return ret;
}

vector<double> calc(int n, vector<pair<double, pair<int, int>>> events) {
	vector<double> res(n, -1);
	vector<int> exi(n, 1);
	sort(all(events));
	for(auto [T, p] : events) {
		auto [u, v] = p;
		if(!exi[u] or !exi[v]) continue;
		exi[u] = exi[v] = 0;
		res[u] = res[v] = T;
	}
	for(auto v : res) assert(v != -1);
	return res;
}

void solve(int n) {
	V<point> stars, vels;
	V<R> radius, vrs;
	rep(n) {
		DBL(x, y, z, vx, vy, vz, r, vr);
		stars.push_back({x, y, z});
		vels.push_back({vx, vy, vz});
		radius.push_back(r);
		vrs.push_back(vr);
	}

	auto dist = [&](R time, int i, int j) {
		point pi = add(stars[i], mult(vels[i], time));
		point pj = add(stars[j], mult(vels[j], time));
		if(n == 2 && time == 0) {
			rep(ii, 3) { debug(pi[ii], pj[ii]); }
		}
		R ans = 0.;
		rep(k, 3) ans += pow(pi[k] - pj[k], 2);
		if(n == 2 && time == 0) {
			debug(sqrt(ans));
		}
		return sqrt(ans) - (radius[i] + radius[j] - time * (vrs[i] + vrs[j]));
	};

	auto atacktime = [&](int i, int j) -> R {
		if(i == j) return radius[i] / vrs[i];
		R maxtime = min(radius[i] / vrs[i], radius[j] / vrs[j]);
		R mintime = 0;
		// if(n == 2) {
		// 	debug(dist(mintime, i, j));
		// 	debug(dist(maxtime, i, j));
		// }
		rep(100) {
			R diff = maxtime - mintime;
			R ml = mintime + diff / 3;
			R mr = (ml + maxtime) / 2;
			if(dist(ml, i, j) < dist(mr, i, j)) {
				maxtime = mr;
			} else {
				mintime = ml;
			}
			if(n == 2)
				if(Counter_in_rep_macro % 20 == 0) {
					debug(mintime, maxtime);
				}
		}
		// if(n == 2) debug(maxtime, dist(1, i, j));
		if(dist(maxtime, i, j) > 0) return R(INF);

		mintime = 0;
		rep(100) {
			R mid = (mintime + maxtime) / 2;
			if(dist(mid, i, j) < 0) {
				maxtime = mid;
			} else {
				mintime = mid;
			}
		}
		return mintime;
	};

	V<pair<double, pair<int, int>>> schedule;

	rep(i, n) rep(j, n) { schedule.emplace_back(atacktime(i, j), pair(i, j)); }
	if(n < 3) debug(schedule);

	auto ans = calc(n, schedule);

	vout(ans, 1);
}

int main() {
	int n;
	while(cin >> n && n) {
		solve(n);
	}
}
accuracy: 1
time_ms: 3560
memory_kb: 4864
final_rank: 20

code_snippet: #include <bits/stdc++.h>

#ifdef _MSC_VER
#  include <intrin.h>
#else
#  include <x86intrin.h>
#endif

#include <limits>
#include <type_traits>

namespace suisen {
// ! utility
template <typename ...Types>
using constraints_t = std::enable_if_t<std::conjunction_v<Types...>, std::nullptr_t>;
template <bool cond_v, typename Then, typename OrElse>
constexpr decltype(auto) constexpr_if(Then&& then, OrElse&& or_else) {
    if constexpr (cond_v) {
        return std::forward<Then>(then);
    } else {
        return std::forward<OrElse>(or_else);
    }
}

// ! function
template <typename ReturnType, typename Callable, typename ...Args>
using is_same_as_invoke_result = std::is_same<std::invoke_result_t<Callable, Args...>, ReturnType>;
template <typename F, typename T>
using is_uni_op = is_same_as_invoke_result<T, F, T>;
template <typename F, typename T>
using is_bin_op = is_same_as_invoke_result<T, F, T, T>;

template <typename Comparator, typename T>
using is_comparator = std::is_same<std::invoke_result_t<Comparator, T, T>, bool>;

// ! integral
template <typename T, typename = constraints_t<std::is_integral<T>>>
constexpr int bit_num = std::numeric_limits<std::make_unsigned_t<T>>::digits;
template <typename T, unsigned int n>
struct is_nbit { static constexpr bool value = bit_num<T> == n; };
template <typename T, unsigned int n>
static constexpr bool is_nbit_v = is_nbit<T, n>::value;

// ?
template <typename T>
struct safely_multipliable {};
template <>
struct safely_multipliable<int> { using type = long long; };
template <>
struct safely_multipliable<long long> { using type = __int128_t; };
template <>
struct safely_multipliable<unsigned int> { using type = unsigned long long; };
template <>
struct safely_multipliable<unsigned long int> { using type = __uint128_t; };
template <>
struct safely_multipliable<unsigned long long> { using type = __uint128_t; };
template <>
struct safely_multipliable<float> { using type = float; };
template <>
struct safely_multipliable<double> { using type = double; };
template <>
struct safely_multipliable<long double> { using type = long double; };
template <typename T>
using safely_multipliable_t = typename safely_multipliable<T>::type;

template <typename T, typename = void>
struct rec_value_type {
    using type = T;
};
template <typename T>
struct rec_value_type<T, std::void_t<typename T::value_type>> {
    using type = typename rec_value_type<typename T::value_type>::type;
};
template <typename T>
using rec_value_type_t = typename rec_value_type<T>::type;

} // namespace suisen

// ! type aliases
using i128 = __int128_t;
using u128 = __uint128_t;

template <typename T>
using pq_greater = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T, typename U>
using umap = std::unordered_map<T, U>;

// ! macros (capital: internal macro)
#define OVERLOAD2(_1,_2,name,...) name
#define OVERLOAD3(_1,_2,_3,name,...) name
#define OVERLOAD4(_1,_2,_3,_4,name,...) name

#define REP4(i,l,r,s)  for(std::remove_reference_t<std::remove_const_t<decltype(r)>>i=(l);i<(r);i+=(s))
#define REP3(i,l,r)    REP4(i,l,r,1)
#define REP2(i,n)      REP3(i,0,n)
#define REPINF3(i,l,s) for(std::remove_reference_t<std::remove_const_t<decltype(l)>>i=(l);;i+=(s))
#define REPINF2(i,l)   REPINF3(i,l,1)
#define REPINF1(i)     REPINF2(i,0)
#define RREP4(i,l,r,s) for(std::remove_reference_t<std::remove_const_t<decltype(r)>>i=(l)+fld((r)-(l)-1,s)*(s);i>=(l);i-=(s))
#define RREP3(i,l,r)   RREP4(i,l,r,1)
#define RREP2(i,n)     RREP3(i,0,n)

#define rep(...)    OVERLOAD4(__VA_ARGS__, REP4   , REP3   , REP2   )(__VA_ARGS__)
#define rrep(...)   OVERLOAD4(__VA_ARGS__, RREP4  , RREP3  , RREP2  )(__VA_ARGS__)
#define repinf(...) OVERLOAD3(__VA_ARGS__, REPINF3, REPINF2, REPINF1)(__VA_ARGS__)

#define CAT_I(a, b) a##b
#define CAT(a, b) CAT_I(a, b)
#define UNIQVAR(tag) CAT(tag, __LINE__)
#define loop(n) for (std::remove_reference_t<std::remove_const_t<decltype(n)>> UNIQVAR(loop_variable) = n; UNIQVAR(loop_variable) --> 0;)

#define all(iterable) std::begin(iterable), std::end(iterable)
#define input(type, ...) type __VA_ARGS__; read(__VA_ARGS__)

#ifdef LOCAL
#  define debug(...) debug_internal(#__VA_ARGS__, __VA_ARGS__)

template <class T, class... Args>
void debug_internal(const char* s, T&& first, Args&&... args) {
    constexpr const char* prefix = "[\033[32mDEBUG\033[m] ";
    constexpr const char* open_brakets = sizeof...(args) == 0 ? "" : "(";
    constexpr const char* close_brakets = sizeof...(args) == 0 ? "" : ")";
    std::cerr << prefix << open_brakets << s << close_brakets << ": " << open_brakets << std::forward<T>(first);
    ((std::cerr << ", " << std::forward<Args>(args)), ...);
    std::cerr << close_brakets << "\n";
}

#else
#  define debug(...) void(0)
#endif

// ! I/O utilities

// __int128_t
std::ostream& operator<<(std::ostream& dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char* d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}
// __uint128_t
std::ostream& operator<<(std::ostream& dest, __uint128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        char buffer[128];
        char* d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[value % 10];
            value /= 10;
        } while (value != 0);
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

// pair
template <typename T, typename U>
std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& a) {
    return out << a.first << ' ' << a.second;
}
// tuple
template <unsigned int N = 0, typename ...Args>
std::ostream& operator<<(std::ostream& out, const std::tuple<Args...>& a) {
    if constexpr (N >= std::tuple_size_v<std::tuple<Args...>>) {
        return out;
    } else {
        out << std::get<N>(a);
        if constexpr (N + 1 < std::tuple_size_v<std::tuple<Args...>>) {
            out << ' ';
        }
        return operator<<<N + 1>(out, a);
    }
}
// vector
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& a) {
    for (auto it = a.begin(); it != a.end();) {
        out << *it;
        if (++it != a.end()) out << ' ';
    }
    return out;
}
// array
template <typename T, size_t N>
std::ostream& operator<<(std::ostream& out, const std::array<T, N>& a) {
    for (auto it = a.begin(); it != a.end();) {
        out << *it;
        if (++it != a.end()) out << ' ';
    }
    return out;
}
inline void print() { std::cout << '\n'; }
template <typename Head, typename... Tail>
inline void print(const Head& head, const Tail &...tails) {
    std::cout << head;
    if (sizeof...(tails)) std::cout << ' ';
    print(tails...);
}
template <typename Iterable>
auto print_all(const Iterable& v, std::string sep = " ", std::string end = "\n") -> decltype(std::cout << *v.begin(), void()) {
    for (auto it = v.begin(); it != v.end();) {
        std::cout << *it;
        if (++it != v.end()) std::cout << sep;
    }
    std::cout << end;
}

__int128_t parse_i128(std::string& s) {
    __int128_t ret = 0;
    for (int i = 0; i < int(s.size()); i++) if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
    if (s[0] == '-') ret = -ret;
    return ret;
}
__uint128_t parse_u128(std::string& s) {
    __uint128_t ret = 0;
    for (int i = 0; i < int(s.size()); i++) if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
    return ret;
}
// __int128_t
std::istream& operator>>(std::istream& in, __int128_t& v) {
    std::string s;
    in >> s;
    v = parse_i128(s);
    return in;
}
// __uint128_t
std::istream& operator>>(std::istream& in, __uint128_t& v) {
    std::string s;
    in >> s;
    v = parse_u128(s);
    return in;
}
// pair
template <typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& a) {
    return in >> a.first >> a.second;
}
// tuple
template <unsigned int N = 0, typename ...Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& a) {
    if constexpr (N >= std::tuple_size_v<std::tuple<Args...>>) {
        return in;
    } else {
        return operator>><N + 1>(in >> std::get<N>(a), a);
    }
}
// vector
template <typename T>
std::istream& operator>>(std::istream& in, std::vector<T>& a) {
    for (auto it = a.begin(); it != a.end(); ++it) in >> *it;
    return in;
}
// array
template <typename T, size_t N>
std::istream& operator>>(std::istream& in, std::array<T, N>& a) {
    for (auto it = a.begin(); it != a.end(); ++it) in >> *it;
    return in;
}
template <typename ...Args>
void read(Args &...args) {
    (std::cin >> ... >> args);
}

// ! integral utilities

// Returns pow(-1, n)
template <typename T>
constexpr inline int pow_m1(T n) {
    return -(n & 1) | 1;
}
// Returns pow(-1, n)
template <>
constexpr inline int pow_m1<bool>(bool n) {
    return -int(n) | 1;
}

// Returns floor(x / y)
template <typename T>
constexpr inline T fld(const T x, const T y) {
    return (x ^ y) >= 0 ? x / y : (x - (y + pow_m1(y >= 0))) / y;
}
template <typename T>
constexpr inline T cld(const T x, const T y) {
    return (x ^ y) <= 0 ? x / y : (x + (y + pow_m1(y >= 0))) / y;
}

template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u32(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u32(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u64(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clzll(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctzll(x) : suisen::bit_num<T>; }
template <typename T>
constexpr inline int floor_log2(const T x) { return suisen::bit_num<T> -1 - count_lz(x); }
template <typename T>
constexpr inline int ceil_log2(const T x) { return floor_log2(x) + ((x & -x) != x); }
template <typename T>
constexpr inline int kth_bit(const T x, const unsigned int k) { return (x >> k) & 1; }
template <typename T>
constexpr inline int parity(const T x) { return popcount(x) & 1; }

// ! container

template <typename T, typename Comparator, suisen::constraints_t<suisen::is_comparator<Comparator, T>> = nullptr>
auto priqueue_comp(const Comparator comparator) {
    return std::priority_queue<T, std::vector<T>, Comparator>(comparator);
}

template <typename Iterable>
auto isize(const Iterable& iterable) -> decltype(int(iterable.size())) {
    return iterable.size();
}

template <typename T, typename Gen, suisen::constraints_t<suisen::is_same_as_invoke_result<T, Gen, int>> = nullptr>
auto generate_vector(int n, Gen generator) {
    std::vector<T> v(n);
    for (int i = 0; i < n; ++i) v[i] = generator(i);
    return v;
}
template <typename T>
auto generate_range_vector(T l, T r) {
    return generate_vector(r - l, [l](int i) { return l + i; });
}
template <typename T>
auto generate_range_vector(T n) {
    return generate_range_vector(0, n);
}

template <typename T>
void sort_unique_erase(std::vector<T>& a) {
    std::sort(a.begin(), a.end());
    a.erase(std::unique(a.begin(), a.end()), a.end());
}

template <typename InputIterator, typename BiConsumer>
auto foreach_adjacent_values(InputIterator first, InputIterator last, BiConsumer f) -> decltype(f(*first++, *last), void()) {
    if (first != last) for (auto itr = first, itl = itr++; itr != last; itl = itr++) f(*itl, *itr);
}
template <typename Container, typename BiConsumer>
auto foreach_adjacent_values(Container c, BiConsumer f) -> decltype(c.begin(), c.end(), void()) {
    foreach_adjacent_values(c.begin(), c.end(), f);
}

// ! other utilities

// x <- min(x, y). returns true iff `x` has chenged.
template <typename T>
inline bool chmin(T& x, const T& y) {
    if (y >= x) return false;
    x = y;
    return true;
}
// x <- max(x, y). returns true iff `x` has chenged.
template <typename T>
inline bool chmax(T& x, const T& y) {
    if (y <= x) return false;
    x = y;
    return true;
}

template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::string bin(T val, int bit_num = -1) {
    std::string res;
    if (bit_num >= 0) {
        for (int bit = bit_num; bit-- > 0;) res += '0' + ((val >> bit) & 1);
    } else {
        for (; val; val >>= 1) res += '0' + (val & 1);
        std::reverse(res.begin(), res.end());
    }
    return res;
}

template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::vector<T> digits_low_to_high(T val, T base = 10) {
    std::vector<T> res;
    for (; val; val /= base) res.push_back(val % base);
    if (res.empty()) res.push_back(T{ 0 });
    return res;
}
template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::vector<T> digits_high_to_low(T val, T base = 10) {
    auto res = digits_low_to_high(val, base);
    std::reverse(res.begin(), res.end());
    return res;
}

template <typename T>
std::string join(const std::vector<T>& v, const std::string& sep, const std::string& end) {
    std::ostringstream ss;
    for (auto it = v.begin(); it != v.end();) {
        ss << *it;
        if (++it != v.end()) ss << sep;
    }
    ss << end;
    return ss.str();
}

namespace suisen {}
using namespace suisen;
using namespace std;

struct io_setup {
    io_setup(int precision = 20) {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(precision);
    }
} io_setup_ {};

// ! code from here

#include <tuple>

namespace suisen {
    namespace internal::tuple_ops {
        template <std::size_t N, typename F, typename ...Args>
        std::tuple<Args...>& update(std::tuple<Args...> &lhs, F &&fun) {
            if constexpr (N == std::tuple_size_v<std::tuple<Args...>>) return lhs;
            else return fun(std::get<N>(lhs)), update<N + 1>(lhs, std::forward<F>(fun));
        }
        template <std::size_t N, typename F, typename ...Args>
        std::tuple<Args...>& merge(std::tuple<Args...> &lhs, const std::tuple<Args...>& rhs, F &&fun) {
            if constexpr (N == std::tuple_size_v<std::tuple<Args...>>) return lhs;
            else return fun(std::get<N>(lhs), std::get<N>(rhs)), merge<N + 1>(lhs, rhs, std::forward<F>(fun));
        }
    }
    template <typename ...Args>
    std::tuple<Args...>& operator+=(std::tuple<Args...>& t1, const std::tuple<Args...>& t2) {
        return internal::tuple_ops::merge<0>(t1, t2, [](auto &x, const auto &y) { x += y; });
    }
    template <typename ...Args>
    std::tuple<Args...>& operator-=(std::tuple<Args...>& t1, const std::tuple<Args...>& t2) {
        return internal::tuple_ops::merge<0>(t1, t2, [](auto &x, const auto &y) { x -= y; });
    }
    template <typename ...Args>
    std::tuple<Args...> operator+(std::tuple<Args...> t1, const std::tuple<Args...>& t2) { return std::move(t1 += t2); }
    template <typename ...Args>
    std::tuple<Args...> operator-(std::tuple<Args...> t1, const std::tuple<Args...>& t2) { return std::move(t1 -= t2); }
    
    template <typename V, typename ...Args>
    std::tuple<Args...>& operator*=(std::tuple<Args...>& t1, const V &v) { return internal::tuple_ops::update<0>(t1, [&v](auto &x) { x *= v; }); }
    template <typename V, typename ...Args>
    std::tuple<Args...>& operator/=(std::tuple<Args...>& t1, const V &v) { return internal::tuple_ops::update<0>(t1, [&v](auto &x) { x /= v; }); }

    template <typename V, typename ...Args>
    std::tuple<Args...> operator*(const V &v, std::tuple<Args...> t1) { return std::move(t1 *= v); }
    template <typename V, typename ...Args>
    std::tuple<Args...> operator*(std::tuple<Args...> t1, const V &v) { return std::move(t1 *= v); }
    template <typename V, typename ...Args>
    std::tuple<Args...> operator/(std::tuple<Args...> t1, const V &v) { return std::move(t1 /= v); }
} // namespace suisen

using fp = double;

fp eps = 1e-9;

using point = tuple<fp, fp, fp>;

void solve() {
    input(int, n);

    if (n == 0) exit(0);

    vector<tuple<point, point, fp, fp>> s(n);
    for (auto &[p, v, r, vr] : s) {
        read(p, v, r, vr);
    }

    using event = tuple<fp, int, int>;

    vector<event> events;
    rep(i, n) rep(j, i) {
        auto [pi, vi, ri, ki] = s[i];
        auto [pj, vj, rj, kj] = s[j];

        auto [x, y, z] = pi - pj;
        auto [vx, vy, vz] = vi - vj;

        fp max_time = min(ri / ki, rj / kj);

        fp la = vx * vx + vy * vy + vz * vz;
        fp lb = 2 * (x * vx + y * vy + z * vz);
        fp lc = x * x + y * y + z * z;

        fp ra = (ki + kj) * (ki + kj);
        fp rb = -2 * (ri + rj) * (ki + kj);
        fp rc = (ri + rj) * (ri + rj);

        fp a = la - ra;
        fp b = lb - rb;
        fp c = lc - rc;

        if (a < 0) a = -a, b = -b, c = -c;

        fp collision_time = 1e100;
        
        if (a < eps) {
            if (abs(b) < eps) assert(false);
            fp t = -c / b;
            if (t > 0) chmin(collision_time, t);
        } else {
            b /= a, c /= a;
            if (b * b - 4 * c >= 0) {
                fp d = sqrt(b * b - 4 * c);
                fp t1, t2;
                if (b < 0) {
                    t1 = (-b + d) / 2, t2 = (2 * c) / (-b + d);
                } else {
                    t1 = -(2 * c) / (b + d), t2 = -(b + d) / 2;
                }
                if (t1 > 0) chmin(collision_time, t1);
                if (t2 > 0) chmin(collision_time, t2);
            }
        }
        if (collision_time < max_time) {
            events.emplace_back(collision_time, i, j);
        }
    }
    rep(i, n) {
        auto [pi, vi, ri, ki] = s[i];
        events.emplace_back(ri / ki, i, -1);
    }

    sort(all(events));
    vector<fp> ans(n, -1);

    for (auto [t, i, j] : events) {
        if (j >= 0) {
            if (ans[i] < 0 and ans[j] < 0) {
                ans[i] = ans[j] = t;
            }
        } else {
            if (ans[i] < 0) {
                ans[i] = t;
            }
        }
    }

    print_all(ans, "\n");
}

int main() {
    while (true) solve();
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3644
final_rank: 1

code_snippet: #include "bits/stdc++.h"
using namespace std;

typedef string::const_iterator State;
#define eps 1e-8L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
#define REP(a, b) for (long long(a) = 0; (a) < (b); ++(a))
#define ALL(x) (x).begin(), (x).end()

#define int long long

ld crossing_point(tuple<ld, ld, ld, ld, ld, ld, ld, ld> A, tuple<ld, ld, ld, ld, ld, ld, ld, ld> B)
{
  ld X2 = 0;
  ld X1 = 0;
  ld X0 = 0;
  ld C = get<3>(B) - get<3>(A);
  ld D = get<0>(B) - get<0>(A);
  X2 += C * C;
  X1 += 2 * C * D;
  X0 += D * D;

  C = get<4>(B) - get<4>(A);
  D = get<1>(B) - get<1>(A);
  X2 += C * C;
  X1 += 2 * C * D;
  X0 += D * D;

  C = get<5>(B) - get<5>(A);
  D = get<2>(B) - get<2>(A);
  X2 += C * C;
  X1 += 2 * C * D;
  X0 += D * D;

  C = get<6>(B) + get<6>(A);
  D = get<7>(B) + get<7>(A);
  X2 -= D * D;
  X1 += 2 * C * D;
  X0 -= C * C;
  if (abs(X2) < eps)
    return 1e18;
  if (X1 * X1 - 4 * X2 * X0 + eps < 0)
    return 1e18;
  vector<ld> go;
  go.push_back((-X1 + sqrt(X1 * X1 - 4 * X2 * X0)) / (2 * X2));
  go.push_back((-X1 - sqrt(X1 * X1 - 4 * X2 * X0)) / (2 * X2));
  if (go[0] > go[1])
    swap(go[0], go[1]);
  if (go[1] < eps)
    return 1e18;
  if (go[0] < eps)
    return go[1];
  return go[0];
}

void solve()
{
  int n;
  cin >> n;
  if (n == 0)
    exit(0);
  vector<tuple<ld, ld, ld, ld, ld, ld, ld, ld>> inputs;
  REP(i, n)
  {
    ld a, b, c, d, e, f, g, h;
    cin >> a >> b >> c >> d >> e >> f >> g >> h;
    inputs.push_back({a, b, c, d, e, f, g, h});
  }
  vector<ld> ans(n, -1);
  vector<pair<ld, pair<ld, ld>>> nexts;
  REP(i, n)
  {
    nexts.push_back({get<6>(inputs[i]) / get<7>(inputs[i]), {i, i}});
    for (int q = i + 1; q < n; ++q)
    {
      nexts.push_back({crossing_point(inputs[i], inputs[q]), {i, q}});
    }
  }

  sort(ALL(nexts));
  for (auto x : nexts)
  {
    if (ans[x.second.first] != -1 or ans[x.second.second] != -1)
    {
      continue;
    }
    ans[x.second.first] = x.first;
    ans[x.second.second] = x.first;
  }

  REP(i, n)
  {
    cout << ans[i] << endl;
  }
}

#undef int

// generated by oj-template v4.7.2
// (https://github.com/online-judge-tools/template-generator)
int main()
{
  // Fasterize input/output script
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  // scanf/printf user should delete this fasterize input/output script

  int t = 1000;
  // cin >> t; // comment out if solving multi testcase
  for (int testCase = 1; testCase <= t; ++testCase)
  {
    solve();
  }
  return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 5788
final_rank: 18

code_snippet: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <functional>
#include <assert.h>

using namespace std;

////////////////	型名など
typedef long long ll;
#define endl '\n'

////////////////	各種定数
const ll INF = 1LL << 60;
const double EPS = 1e-12;

////////////////	便利なテンプレート関数
template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

class Vec3 {// 点
public:
	double x, y, z;

	Vec3() {
		x = 0, y = 0, z = 0;
	}
	Vec3(double X, double Y, double Z) {
		x = X, y = Y, z = Z;
	}
	Vec3(const Vec3& other) {
		x = other.x, y = other.y, z = other.z;
	}

	inline Vec3& operator = (const Vec3& other) {
		x = other.x, y = other.y, z = other.z;
		return *this;
	}
	inline bool operator ==(const Vec3& other) {
		return ((abs(x - other.x) < EPS) && (abs(y - other.y) < EPS) && abs(z - other.z) < EPS);
	}
	inline bool operator !=(const Vec3& other) {
		return !(*this == other);
	}
	inline Vec3& operator += (const Vec3& other) {
		x += other.x, y += other.y, z += other.z;
		return *this;
	}
	inline Vec3& operator -= (const Vec3& other) {
		x -= other.x, y -= other.y, z -= other.z;
		return *this;
	}
	inline Vec3& operator *= (double param) {
		x *= param, y *= param, z *= param;
		return *this;
	}
	inline Vec3& operator /= (double param) {
		assert(abs(param) >= EPS);
		x /= param, y /= param, z /= param;
		return *this;
	}
	inline Vec3 operator + (const Vec3& other) {
		Vec3 v = *this; v += other;
		return v;
	}
	inline Vec3 operator - (const Vec3& other) {
		Vec3 v = *this; v -= other;
		return v;
	}
	inline Vec3 operator * (double param) {
		Vec3 v = *this; v *= param;
		return v;
	}
	inline Vec3 operator / (double param) {
		Vec3 v = *this; v /= param;
		return v;
	}
	inline double length2() const {
		return x * x + y * y + z * z;
	}
	inline double length() const {
		return sqrt(length2());
	}
	inline double dot(Vec3 other) const {
		return x * other.x + y * other.y + z * other.z;
	}
	inline void normalize() {
		double rate = length();
		if (rate < EPS) {
			x = 1, y = 0, z = 0;
		}
		else {
			rate = 1.0 / rate;
			x *= rate;
			y *= rate;
			z *= rate;
		}
	}
};



int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(0);

	while (1) {
		int N; cin >> N;
		if (N == 0) { break; }
		
		vector<Vec3> _P(N), _VP(N);
		vector<double> _R(N), _VR(N);

		for (int i = 0; i < N; i++) {
			cin >> _P[i].x >> _P[i].y >> _P[i].z >> _VP[i].x >> _VP[i].y >> _VP[i].z >> _R[i] >> _VR[i];
		}

		set<pair<double, pair<double, double>>> events;

		for (int i = 0; i < N; i++) {
			double T = _R[i] / _VR[i];
			events.insert({ T, {i, -1} });
		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				Vec3 P = _P[i] - _P[j];
				Vec3 V = _VP[i] - _VP[j];
				double R = _R[i] + _R[j];
				double VR = _VR[i] + _VR[j];

				double A = VR * VR - V.length2();
				double B = R * VR + P.dot(V);
				double C = R * R - P.length2();

				if (abs(A) < EPS) {
					if (abs(B) > EPS) {
						double T = C / (2 * B);
						if (T > 0 && C < 0) {
							events.insert({ T, {i, j} });
						}
					}
				}
				else {
					B /= A;
					C /= A;
					C = B * B - C;
					if (C > 0) {
						C = sqrt(C);
						double T1 = B - C, T2 = B + C;
						if (T1 > 0) {
							events.insert({ T1, {i, j} });
						}
						else if (T2 > 0) {
							events.insert({ T2, {i, j} });
						}
					}
				}


			}
		}

		vector<double> vanish(N, 1000000);
		for (auto& e : events) {
			auto p = e.second;
			if (p.second == -1) {
				chmin(vanish[p.first], e.first);
			}
			else {
				if (min(vanish[p.first], vanish[p.second]) > e.first) {
					chmin(vanish[p.first], e.first);
					chmin(vanish[p.second], e.first);
				}
			}
		}

		for (int i = 0; i < N; i++) {
			cout << fixed << setprecision(8) << vanish[i] << endl;
		}
	}

	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 4536
final_rank: 12