#include #include #include #include #define int long long int z; int o = !z; int two = o << o; int seven = std::minus()(two << two, o); int MOD; std::vector> a, b; int suc(int& x) { return x = std::plus()(x, o); } std::vector> mul(std::vector> x, std::vector> y) { std::vector> r(x.size(), std::vector(y[z].size(), z)); for (int i = z; i < x.size(); suc(i)) { for (int j = z; j < y[z].size(); suc(j)) { for (int k = z; k < x[z].size(); suc(k)) { r[i][j] = std::modulus()(std::plus()(r[i][j], std::multiplies()(x[i][k], y[k][j])), MOD); } } } return r; } void pow_(int p) { while (p) { if (p & o) a = mul(a, b); b = mul(b, b); p >>= o; } } int solve(int n) { if (n == o) return o; a = std::vector>(two, std::vector(two, o)); a[o][o] = z; b = a; pow_(std::minus()(n, two)); return std::modulus()(std::plus()(a[z][z], (a[z][o] << o)), MOD); } void init_mod() { std::string s; s = std::plus()(s, std::to_string(o)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(z)); s = std::plus()(s, std::to_string(seven)); MOD = std::stoi(s); } signed main() { init_mod(); int t; std::cin >> t; for (int _ = z; _ < t; suc(_)) { int n; std::cin >> n; std::cout << solve(n) << std::endl; } return z; }