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