#include using namespace std; const int MAX = 200; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); int T; cin >> T; for (int i = 0; i < T; i++){ int N; double x; cin >> N >> x; cout << (complex(0, -0.5) * (pow(complex(x, -1), -(N + 1)) - pow(complex(x, 1), -(N + 1)))).real() * pow(x * x + 1, (double) N / 2 + 1) * pow(-1, N) << endl; } }