for _ in range(int(input())): p, K = input().split() p = float(p) K = int(K) dp = [0] * (K + 1) dp[0] = 0 wa = 0 for i in range(1, K): dp[i] = (1 - wa) * p wa += dp[i] dp[K] = (1 - wa) ans = 0 for i in range(1, K + 1): ans += i * dp[i] print(ans)