import math import scipy.misc T = int(input()) def f(x): return 1 / (x*x + 1) for _ in range(T): n, x = input().split() n = int(n) x = float(x) res = scipy.misc.derivative(f, x, 1.0E-6, n, order=(n+1)//2*2+1) res *= (x*x + 1)**(n/2 + 1) / math.factorial(n) print(res)