#include<bits/stdc++.h>
#define X first
#define Y second
#define eb push_back
#define siz(a) int(a.size())
#define endl "\n"
#define trace2(x, y) cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z) cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
using namespace std;
typedef long long int ll;
typedef vector < int > vi;
typedef vector < ll > vll;
const int mod=1e9+7;
const int maxn=1e6+5;
/* finding inverse upto n
* for i in xrange(2, N):
ifc[i] = -(mod / i) * ifc[mod % i] % mod
*
*/
ll power(ll base, ll exp, ll mod){ll res = 1; while(exp){if(exp%2)res*=base;base*=base;res%=mod;base%=mod;exp/=2;}return res;}
ll t, n, v[maxn], x[maxn];
double dp[2][55];
vector<pair<ll, ll> > vv;
double go(int idx, bool dir){
if(idx == n+1)
return (double)1e18;
double &ret = dp[dir][idx];
if(ret != -1)
return ret;
for(int i = 0; i<2; i++){
if(idx == 1){
ret = max(ret, go(idx+1, i));
}
}
//left
if(dir){
double ans = 1e18;
if(v[idx] > v[idx-1]){
ans = 1.0*(x[idx] - x[idx-1])/(v[idx] - v[idx-1]);
} else if(v[idx] == v[idx-1]){
if(x[idx] == x[idx-1])
ans = 0;
}
ret = max(ret, min(go(idx+1, dir), ans));
ret = max(ret, go(idx+1, !dir));
} else{
double ans = 1e18;
if(v[idx] < v[idx-1]){
ans = -1.0*(x[idx] - x[idx-1])/(v[idx] - v[idx-1]);
} else if(v[idx] == v[idx-1]){
if(x[idx] == x[idx-1])
ans = 0;
}
ret = max(ret, min(go(idx+1, dir), ans));
ans = 1.0*(x[idx] - x[idx-1])/(v[idx] + v[idx-1]);
ret = max(ret , min(go(idx+1, !dir), ans));
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
//freopen("input.in", "r", stdin);freopen("output.out", "w", stdout);
cin >> t;
while(t--){
cin >> n;
vv.clear();
for(int i=1; i<=n; i++){
cin >> x[i] >> v[i];
dp[0][i] = -1;
dp[1][i] = -1;
vv.eb({x[i], v[i]});
}
sort(vv.begin(), vv.end());
for(int i=1; i<=n; i++){
x[i] = vv[i-1].X;
v[i] = vv[i-1].Y;
}
double ans = go(1, 0);
if(ans >= 1e17)
cout << -1 << endl;
else
cout << fixed << setprecision(10) << ans << endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCiNkZWZpbmUgWCBmaXJzdAojZGVmaW5lIFkgc2Vjb25kCiNkZWZpbmUgZWIgcHVzaF9iYWNrCiNkZWZpbmUgc2l6KGEpIGludChhLnNpemUoKSkKI2RlZmluZSBlbmRsICJcbiIKCiNkZWZpbmUgdHJhY2UyKHgsIHkpICAgICAgICAgICAgIGNlcnIgPDwjeDw8IjogIjw8eDw8IiB8ICI8PCN5PDwiOiAiPDx5PDwgZW5kbDsKI2RlZmluZSB0cmFjZTMoeCwgeSwgeikgICAgICAgICAgY2VyciA8PCN4PDwiOiAiPDx4PDwiIHwgIjw8I3k8PCI6ICI8PHk8PCIgfCAiPDwjejw8IjogIjw8ejw8ZW5kbDsKI2RlZmluZSB0cmFjZTQoYSwgYiwgYywgZCkgICAgICAgY2VyciA8PCNhPDwiOiAiPDxhPDwiIHwgIjw8I2I8PCI6ICI8PGI8PCIgfCAiPDwjYzw8IjogIjw8Yzw8IiB8ICI8PCNkPDwiOiAiPDxkPDxlbmRsOwojZGVmaW5lIHRyYWNlNShhLCBiLCBjLCBkLCBlKSAgICBjZXJyIDw8I2E8PCI6ICI8PGE8PCIgfCAiPDwjYjw8IjogIjw8Yjw8IiB8ICI8PCNjPDwiOiAiPDxjPDwiIHwgIjw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