local q = io.read("*n") for iq = 1, q do local p, k = io.read("*n", "*n") local z = 0 local rate = 1 for i = 1, k - 1 do z = z + i * rate * p rate = rate * (1 - p) end z = z + rate * k print(z) end