#include #define GET_MACRO(a, b, c, NAME, ...) NAME #define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define rep2(i, a) rep3 (i, 0, a) #define rep3(i, a, b) for (int i = (a); i < (b); i++) #define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__) #define repr2(i, a) repr3 (i, 0, a) #define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define chmin(a, b) ((b) < a && (a = (b), true)) #define chmax(a, b) (a < (b) && (a = (b), true)) using namespace std; typedef long long ll; typedef long double D; typedef vector vec; typedef vector mat; mat mul(mat &A, mat &B) { mat res(A.size(), vec(B[0].size())); rep (i, A.size()) rep (j, B[0].size()) rep (k, A[0].size()) { res[i][j] += A[i][k] * B[k][j]; } return res; } mat pow(mat A, ll b) { mat res(A.size(), vec(A.size())); rep (i, A.size()) res[i][i] = 1; while (b) { if (b & 1) res = mul(res, A); A = mul(A, A); b /= 2; } return res; } mat companion(vector a) { int n = a.size(); mat res(n + 1, vec(n + 1)); rep (i, n - 1) res[i][i + 1] = 1; rep (i, n) res[n - 1][i] = a[i]; res[n][1] = res[n][n] = 1; return res; } pair calc(vector a, ll n) { int k = a.size(); mat A = companion(a); A = pow(A, n); return make_pair(A[k][4], A[k][5]); } int main() { int T; cin >> T; D p = 1.0 / 6; vector a(6, p); rep (i_, T) { ll N; cin >> N; auto q = calc(a, N + 4); D s, t; tie(s, t) = calc(a, N + 4); D ans = t / (s - t * 5.0 / 6.0); printf("%.20f\n", (double)ans); } return 0; }