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