#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int modulo(int, long, int);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long t;
  int i;
  scanf("%ld", &t);
  for (i = 1; i <= t; i++) {
    long int n;
    long long int ans;
    scanf("%ld", &n);
    long long int inv = modulo(6, 1000000007 - 2, 1000000007);
    if (n % 2)
      ans = (7 * modulo(2, n, 1000000007) - 8) * inv;
    else
      ans = (7 * modulo(2, n, 1000000007) + 8) * inv;
    printf("%lld\n", ans % 1000000007);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     121e <main+0xee>
lea    0xe95(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x6,%edi
mov    $0x3b9aca05,%esi
mov    $0x3b9aca07,%edx
call   1040 <modulo@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     11cf <main+0x9f>
mov    -0x20(%rbp),%rsi
mov    $0x2,%edi
mov    $0x3b9aca07,%edx
call   1040 <modulo@plt>
imul   $0x7,%eax,%eax
sub    $0x8,%eax
cltq
imul   -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11f3 <main+0xc3>
mov    -0x20(%rbp),%rsi
mov    $0x2,%edi
mov    $0x3b9aca07,%edx
call   1040 <modulo@plt>
imul   $0x7,%eax,%eax
add    $0x8,%eax
cltq
imul   -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <main+0x26>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
jle    1218 <main+0xe8>
mov    $0x1,%ebx
lea    0x10(%rsp),%r15
movabs $0x89705f3112a28fe5,%r13
5f 70 89
lea    0xe8e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
lea    0xe79(%rip),%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    $0x3b9aca05,%esi
mov    $0x6,%edi
mov    $0x3b9aca07,%edx
call   1040 <modulo@plt>
movslq %eax,%rbp
mov    0x10(%rsp),%rsi
xor    %r14d,%r14d
test   $0x1,%sil
sete   %r14b
mov    $0x2,%edi
mov    $0x3b9aca07,%edx
call   1040 <modulo@plt>
lea    0x0(,%rax,8),%ecx
sub    %eax,%ecx
shl    $0x4,%r14d
lea    (%r14,%rcx,1),%eax
add    $0xfffffff8,%eax
movslq %eax,%rsi
imul   %rbp,%rsi
mov    %rsi,%rax
imul   %r13
add    %rsi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rsi
mov    %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,0x8(%rsp)
jge    1180 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
store i32 1, i32* %3
br label %8
8: ; preds = %40, %0
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = load i64, i64* %2
%12 = icmp sle i64 %10, %11
br i1 %12, label %13, label %43
13: ; preds = %8
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %4)
%15 = call i32 @modulo(i32 6, i64 1000000005, i32 1000000007)
%16 = sext i32 %15 to i64
store i64 %16, i64* %6
%17 = load i64, i64* %4
%18 = srem i64 %17, 2
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %13
%21 = load i64, i64* %4
%22 = call i32 @modulo(i32 2, i64 %21, i32 1000000007)
%23 = mul nsw i32 7, %22
%24 = sub nsw i32 %23, 8
%25 = sext i32 %24 to i64
%26 = load i64, i64* %6
%27 = mul nsw i64 %25, %26
store i64 %27, i64* %5
br label %36
28: ; preds = %13
%29 = load i64, i64* %4
%30 = call i32 @modulo(i32 2, i64 %29, i32 1000000007)
%31 = mul nsw i32 7, %30
%32 = add nsw i32 %31, 8
%33 = sext i32 %32 to i64
%34 = load i64, i64* %6
%35 = mul nsw i64 %33, %34
store i64 %35, i64* %5
br label %36
36: ; preds = %28, %20
%37 = load i64, i64* %5
%38 = srem i64 %37, 1000000007
%39 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %38)
br label %40
40: ; preds = %36
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %8
43: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%5 = load i64, i64* %1
%6 = icmp slt i64 %5, 1
br i1 %6, label %28, label %7
7: ; preds = %0
%8 = bitcast i64* %2 to i8*
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 1, %7 ], [ %25, %9 ]
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%12 = call i32 @modulo(i32 6, i64 1000000005, i32 1000000007)
%13 = sext i32 %12 to i64
%14 = load i64, i64* %2
%15 = and i64 %14, 1
%16 = icmp eq i64 %15, 0
%17 = call i32 @modulo(i32 2, i64 %14, i32 1000000007)
%18 = mul nsw i32 %17, 7
%19 = select i1 %16, i32 8, i32 -8
%20 = add nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = mul nsw i64 %21, %13
%23 = srem i64 %22, 1000000007
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %23)
%25 = add nuw i64 %10, 1
%26 = load i64, i64* %1
%27 = icmp slt i64 %26, %25
br i1 %27, label %28, label %9
28: ; preds = %9, %0
ret i32 0
}