#include #define LL long long using namespace std;bool h1; int T,n; double ans,b1,a1; bool h2;int main(){ cin>>T; while(T--){ scanf("%d",&n); ans=0.0; for(int i=1;i<=n;i++){ scanf("%lf%lf",&a1,&b1); ans=max(ans,(1.0-b1)/(a1+(1.0-b1))); } printf("%.5lf\n",ans); } return 0; }