#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, j, k, a[100], x;
  long int pro = 1;
  scanf("%d", &j);
  for (i = 0; i < j; i++) {
    scanf("%d", &k);
    for (x = 0; x < k - 1; x++) {
      scanf("%d", &a[x]);
      pro = (pro * a[x]) % 1234567;
    }
    printf("%ld\n", pro);
    pro = 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x1b0(%rbp)
lea    0xebc(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121a <main+0xfa>
lea    0xe99(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ee <main+0xce>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe56(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1b0(%rbp),%rax
movslq -0x1a4(%rbp),%rcx
movslq -0x1a0(%rbp,%rcx,4),%rcx
ff
imul   %rcx,%rax
mov    $0x12d687,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x1b0(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    117a <main+0x5a>
mov    -0x1b0(%rbp),%rsi
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
movq   $0x1,-0x1b0(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11fe <main+0xde>
xor    %r13d,%r13d
lea    0xea9(%rip),%r12
movabs $0x365bb44649a1e167,%rbp
b4 5b 36
jmp    1187 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%r13d
cmp    0xc(%rsp),%r13d
jge    11fe <main+0xde>
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%esi
cmpl   $0x2,0x8(%rsp)
jl     1170 <main+0x50>
mov    $0x1,%r15d
lea    0x10(%rsp),%rbx
xor    %r14d,%r14d
xchg   %ax,%ax
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq (%rbx),%rsi
imul   %r15,%rsi
mov    %rsi,%rax
imul   %rbp
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rdx
add    %rax,%rdx
imul   $0x12d687,%rdx,%rax
sub    %rax,%rsi
add    $0x1,%r14
movslq 0x8(%rsp),%rax
add    $0xffffffffffffffff,%rax
add    $0x4,%rbx
mov    %rsi,%r15
cmp    %rax,%r14
jl     11b0 <main+0x90>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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