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