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