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