import re import sys content = input() pattern = r'^(\d+)$' result = re.match(pattern, content) if not result: sys.exit("format error.") T = int(content) if not (1 <= T and T <= 10**5): sys.exit("T") for _ in range(T): content = input() pattern = r'^(\d+) (-?0.\d{5})$' result = re.match(pattern, content) if not result: sys.exit("format error.") n, x = content.split() n = int(n) x = float(x) if not (0 <= n and n <= 10**5): sys.exit("N") res = ((x - 1j)**(-n-1) - (x + 1j)**(-n-1)) * (-1)**n / 2j res *= (x**2 + 1)**(n/2 + 1) print(res.real)