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