import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; immutable long MOD = 10^^9 + 7; void main() { auto T = readln.chomp.to!int; long a = powmod(3, MOD-2, MOD); long b = 1L; long[][] X = [[a, 0, 0, a, 0, a], [0, a, 0, a, a, 0], [0, 0, a, 0, a, a], [0, 0, b, 0, 0, 0], [b, 0, 0, 0, 0, 0], [0, b, 0, 0, 0, 0]]; while (T--) { auto N = readln.chomp.to!int; auto ans = matpow(6, N, X); ans[0][0].writeln; } } long powmod(long a, long x, long m) { long ret = 1; while (x) { if (x % 2) ret = ret * a % m; a = a * a % m; x /= 2; } return ret; } long[][] matmul(int N, long[][] m1, long[][] m2) { auto ret = new long[][](N, N); foreach (i; 0..N) { foreach (j; 0..N) { ret[i][j] = 0; foreach (k; 0..N) { (ret[i][j] += m1[i][k] * m2[k][j] % MOD) %= MOD; } } } return ret; } long[][] matpow(int N, long K, long[][] mat) { auto ret = new long[][](N, N); foreach (i; 0..N) foreach (j; 0..N) ret[i][j] = i == j ? 1 : 0; while (K > 0) { if (K % 2 == 1) ret = matmul(N, ret, mat); mat = matmul(N, mat, mat); K /= 2; } return ret; }