for _ in range(int(input())): p, k = input().split() p = float(p) k = int(k) s = 0 d = 1 for i in range(k): e = (1 - p) ** i * p s += (i + 1) * e d -= e s += d * k print(s)