#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 /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *);
int main() {
  long long int t, n, a, i, j, k, mult;
  scanf("%lld", &t);
  while (t--) {
    mult = 1;
    scanf("%lld", &n);
    for (i = 0; i < n; i++) {
      scanf("%lld", &a);
      mult = (mult * a) % 1000000007;
    }
    printf("%lld\n", mult);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11d3 <main+0xb3>
movq   $0x1,-0x40(%rbp)
lea    0xe99(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11be <main+0x9e>
lea    0xe73(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x40(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x40(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1178 <main+0x58>
mov    -0x40(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x40,%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    0xecb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
subq   $0x1,0x8(%rsp)
jae    1158 <main+0x38>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea1(%rip),%r13
lea    0x10(%rsp),%r15
movabs $0x89705f3112a28fe5,%rbp
5f 70 89
lea    0xe90(%rip),%r12
jmp    1198 <main+0x78>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%ebx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
subq   $0x1,0x8(%rsp)
jb     1147 <main+0x27>
mov    %r13,%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmpq   $0x0,(%rsp)
jle    1180 <main+0x60>
mov    $0x1,%ebx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
imul   0x10(%rsp),%rbx
mov    %rbx,%rax
imul   %rbp
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rbx
add    $0x1,%r14
cmp    (%rsp),%r14
jl     11c0 <main+0xa0>
jmp    1185 <main+0x65>

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

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