import sys input = sys.stdin.readline T=int(input()) for tests in range(T): p,K=map(float,input().split()) K=int(K) ANS=0 now=1 for i in range(K): if i!=K-1: ANS+=(i+1)*now*p else: ANS+=(i+1)*now now=now*(1-p) print(ANS)