#include #define clr(x) memset(x,0,sizeof(x)) #define clrmax(x) memset(x,0x3f3f3f3f,sizeof(x)) #define clrmin(x) memset(x,-0x3f3f3f3f,sizeof(x)) #define pb push_back #define LL long long #define mod 1000000007 #define mp make_pair using namespace std; typedef pair pii; const int N = 1e2+10; const int M = 3e5+10; int T,n; double b[N],c[N]; int main(){ scanf("%d",&T); while(T --){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lf%lf",&b[i],&c[i]); } double ans = (1 - c[1]) / (1 - c[1] + b[1]); for(int i=2;i<=n;i++){ ans = max((1 - c[i]) / (1 - c[i] + b[i]),ans); } printf("%.5f\n",ans); } return 0; }