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