#define _CRT_SECURE_NO_WARNINGS #include using namespace std; int main() { int T; cin >> T; while (T--) { int n; double x; cin >> n >> x; complex xp(x, 1), xn(x, -1), I(0, 1); auto res = (pow(xn, -n - 1) - pow(xp, -n - 1)) / (2. * I); res *= pow(x * x + 1, n / 2. + 1); cout << fixed << setprecision(5) << res.real() << endl; } }