#include <bits/stdc++.h>

using namespace std;

using ld = long double;

int main() {
    cout << fixed << setprecision(16);
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<array<int, 4>> v(n);
        bool ok = true;
        for (int i = 0; i < n; i++) {
            cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
            if (v[i][1] == 0) ok = false;
        }
        if (!ok) {
            cout << "impossible\n";
            continue;
        }
        sort(v.begin(), v.end(), [&](auto const& v1, auto const& v2) {
            return v1[0] * (v1[1] + v1[2] + v1[3]) * v2[3] < v2[0] * (v2[1] + v2[2] + v2[3]) * v1[3];
        });
        ld ans = 0;
        ld prod = 1;
        for (int i = n - 1; i >= 0; --i) {
            auto [tt, s, f, c] = v[i];
            prod *= (s + c) * 1.0 / s;
            ans += (tt * (s + f + c)) * 1.0 / (s + c) * prod;
        }
        cout << ans << "\n";
    }
}