#include using namespace std; int main() { int T; cin >> T; for( int i = 0; i < T; i++ ) { double p; int K; cin >> p >> K; double ans = 0, pp, rp; if( p == 1 ) ans = 1; else { for( int k = 0; k < K; k++ ) { if( k == 0 ) ans += (k + 1) * p; else if( k == 1 ) { rp = 1 - p; pp = rp; if( k == K - 1 ) ans += (k + 1) * rp; else ans += (k + 1) * rp * p; } else { rp *= pp; if( k == K - 1) ans += (k + 1) * rp; else ans += (k + 1) * rp * p; } } } cout << fixed << setprecision(12) << ans << endl; } }