#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; } int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { ll n, x, y, p, q, r; cin >> n >> x >> y >> p >> q >> r; auto f = [&](ll cnt) -> long double { ll t = x + cnt * y; if (t == 1) return q; ll rest = n - cnt; auto g = [&](ll k) { // q (1+(1-1/t)+(1-/t)^2+...+(1-1/t)^(k-1)) // = pq (1-(1-1/t)^k) long double res = -expm1l(k * log1pl(-1.0L/t)) * t * q; res += (rest - k) * (long double)(__int128(t) * q - r) / t; return res; }; ll l = -1, r = rest + 1; while (r - l > 2) { ll c = (l + r) / 2; if (g(c) < g(c+1)) l = c; else r = c + 1; } return p * cnt + g(l + 1); }; { ll l = -1, r = n + 1; while (r - l > 2) { ll c = (l + r) / 2; if (f(c) < f(c+1)) l = c; else r = c + 1; } cout << fixed << setprecision(12) << f(l + 1) << '\n'; } } }