#include double solve(double p, int K) { int i; double ans = 0.0, tmp; for (i = 1, tmp = 1.0; i < K; i++, tmp *= 1.0 - p) ans += i * tmp * p; return ans + K * tmp; } int main() { int T, K; double p; scanf("%d", &T); while (T--) { scanf("%lf %d", &p, &K); printf("%.6f\n", solve(p, K)); } fflush(stdout); return 0; }