#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int test; scanf("%d", &test);
while(test--){
int n, b[105]; double c[105], ans=0;
scanf("%d", &n);
for(int i=0; i<n; i++) scanf("%d%lf", &b[i], &c[i]);
for(int i=0; i<n; i++){
double t=(1-c[i])/(b[i]+1-c[i]);
ans=max(ans, t);
}
printf("%.5lf\n", ans);
}
return 0;
}
//直接看样例