import java.util.*;

public class agenticdevelopment_AN {
  static class Task implements Comparable<Task> {
    double et;
    double p;
    double cmp;

    public Task(double et, double p) {
      this.et = et;
      this.p = p;
      this.cmp = p == 1 ? Double.MAX_VALUE : et / (1 - p);
    }

    @Override
    public int compareTo(agenticdevelopment_AN.Task o) {
      return Double.compare(cmp, o.cmp);
    }
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int T = s.nextInt();
    for (int tc = 0; tc < T; tc++) {
      int n = s.nextInt();
      int[] t = new int[n];
      int[] S = new int[n];
      int[] F = new int[n];
      int[] C = new int[n];
      boolean impossible = false;
      for (int i = 0; i < n; i++) {
        t[i] = s.nextInt();
        S[i] = s.nextInt();
        F[i] = s.nextInt();
        C[i] = s.nextInt();
        if (S[i] == 0) impossible = true;
      }
      if (impossible) {
        System.out.println("impossible");
        continue;
      }

      Task[] tasks = new Task[n];
      for (int i = 0; i < n; i++) {
        tasks[i] = new Task((1.0 * t[i] * (S[i] + F[i] + C[i])) / (S[i] + C[i]), (1.0 * S[i]) / (S[i] + C[i]));
      }
      Arrays.sort(tasks);
      double num = 0;
      double denom = 1;
      for (int i = n - 1; i >= 0; i--) {
        num *= tasks[i].p;
        num += tasks[i].et;
        denom *= tasks[i].p;
      }
      System.out.println(num / denom);
    }
  }
}
