for _ in range(int(input())): p,k = input().split(); p = float(p); k = int(k) q = 1; x = 0 for i in range(1,k): x += i*q*p; q *= 1-p; print(x+k*q)