#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int t; cin >> t; for (; t--;) { double p; int k; cin >> p >> k; if (p == 0) { cout << k << endl; } else if (p == 1) { cout << 1 << endl; } else { double pk = pow(1 - p, k); double ans = (k * p * pk - p * pk + pk + p - 1) / (p - 1) / p + k * pk / (1 - p); cout << setprecision(16) << fixed << ans << endl; } } }