/**
 *    author:  tourist
 *    created: 21.10.2026 10:53:14
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<double> t(n), s(n), f(n), c(n);
    bool fail = false;
    for (int i = 0; i < n; i++) {
      cin >> t[i] >> s[i] >> f[i] >> c[i];
      if (s[i] == 0) {
        fail = true;
        continue;
      }
      double sum = s[i] + f[i] + c[i];
      s[i] /= sum;
      f[i] /= sum;
      c[i] /= sum;
      t[i] /= 1 - f[i];
      s[i] /= 1 - f[i];
      c[i] /= 1 - f[i];
    }
    if (fail) {
      cout << "impossible" << '\n';
      continue;
    }
    vector<int> order(n);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](int i, int j) {
      return t[i] + s[i] * t[j] < t[j] + s[j] * t[i];
    });
    double ans = 0;
    double prod = 1;
    for (int i : order) {
      ans += prod * t[i];
      prod *= s[i];
    }
    cout << fixed << setprecision(17) << ans / prod << '\n';
  }
  return 0;
}
