#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 *, ...);
int main() {
  int t;
  long long int n, i, j, temp, a, b, c, d, e;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    a = 0;
    b = 1;
    c = 1;
    for (i = 3; i <= n; i++) {
      d = a + b + i * 2;
      d %= 10000003;
      a = b;
      b = c;
      c = d;
    }
    printf("%d\n", d);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11fc <main+0xdc>
lea    0xea4(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x30(%rbp)
movq   $0x1,-0x38(%rbp)
movq   $0x1,-0x40(%rbp)
movq   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11e7 <main+0xc7>
mov    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    $0x989683,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x48(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1187 <main+0x67>
mov    -0x48(%rbp),%rsi
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    1157 <main+0x37>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xea2(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe99(%rip),%r12
movabs $0xd6bf909d086644af,%r13
90 bf d6
jmp    1192 <main+0x72>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1147 <main+0x27>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%r8
cmp    $0x3,%r8
jl     1180 <main+0x60>
jne    11c0 <main+0xa0>
mov    $0x1,%ecx
mov    $0x3,%r11d
xor    %r10d,%r10d
jmp    126e <main+0x14e>
nop
lea    -0x2(%r8),%r9
and    $0xfffffffffffffffe,%r9
neg    %r9
mov    $0x1,%ebx
mov    $0x3,%r11d
mov    $0x8,%edi
mov    $0x1,%esi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%r10
add    %rsi,%rax
lea    (%rdi,%rax,1),%rbx
lea    (%rdi,%rax,1),%rcx
add    $0xfffffffffffffffe,%rcx
mov    %rcx,%rax
imul   %r13
lea    (%rdx,%rbx,1),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x17,%rax
add    %rdx,%rax
imul   $0x989683,%rax,%rax
sub    %rax,%rcx
add    %r10,%rsi
add    %rdi,%rsi
mov    %rsi,%rax
imul   %r13
add    %rsi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x17,%rdx
add    %rax,%rdx
imul   $0x989683,%rdx,%rax
mov    %rsi,%rbx
sub    %rax,%rbx
add    $0x4,%rdi
lea    (%r9,%r11,1),%rdx
add    $0x2,%rdx
add    $0x2,%r11
mov    %rcx,%rsi
mov    %r10,%rax
cmp    $0x3,%rdx
jne    11f0 <main+0xd0>
test   $0x1,%r8b
je     1180 <main+0x60>
add    %r10,%rcx
lea    (%rcx,%r11,2),%rbx
mov    %rbx,%rax
imul   %r13
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x17,%rdx
add    %rax,%rdx
imul   $0x989683,%rdx,%rax
sub    %rax,%rbx
jmp    1180 <main+0x60>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp eq i32 %6, 0
br i1 %8, label %55, label %9
9: ; preds = %0, %49
%10 = phi i64 [ %50, %49 ], [ undef, %0 ]
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64* %2)
%12 = load i64, i64* %2
%13 = icmp slt i64 %12, 3
br i1 %13, label %49, label %14
14: ; preds = %9
%15 = and i64 %12, 1
%16 = icmp eq i64 %12, 3
br i1 %16, label %38, label %17
17: ; preds = %14
%18 = add i64 %12, -2
%19 = and i64 %18, -2
br label %20
20: ; preds = %20, %17
%21 = phi i64 [ 3, %17 ], [ %35, %20 ]
%22 = phi i64 [ 1, %17 ], [ %34, %20 ]
%23 = phi i64 [ 1, %17 ], [ %29, %20 ]
%24 = phi i64 [ 0, %17 ], [ %22, %20 ]
%25 = phi i64 [ 0, %17 ], [ %36, %20 ]
%26 = add nsw i64 %23, %24
%27 = shl nuw nsw i64 %21, 1
%28 = add nsw i64 %26, %27
%29 = srem i64 %28, 10000003
%30 = add nsw i64 %22, %23
%31 = shl i64 %21, 1
%32 = add i64 %31, 2
%33 = add nsw i64 %30, %32
%34 = srem i64 %33, 10000003
%35 = add nuw i64 %21, 2
%36 = add i64 %25, 2
%37 = icmp eq i64 %36, %19
br i1 %37, label %38, label %20
38: ; preds = %20, %14
%39 = phi i64 [ undef, %14 ], [ %34, %20 ]
%40 = phi i64 [ 3, %14 ], [ %35, %20 ]
%41 = phi i64 [ 1, %14 ], [ %29, %20 ]
%42 = phi i64 [ 0, %14 ], [ %22, %20 ]
%43 = icmp eq i64 %15, 0
br i1 %43, label %49, label %44
44: ; preds = %38
%45 = add nsw i64 %41, %42
%46 = shl nuw nsw i64 %40, 1
%47 = add nsw i64 %45, %46
%48 = srem i64 %47, 10000003
br label %49
49: ; preds = %44, %38, %9
%50 = phi i64 [ %10, %9 ], [ %39, %38 ], [ %48, %44 ]
%51 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %50)
%52 = load i32, i32* %1
%53 = add nsw i32 %52, -1
store i32 %53, i32* %1
%54 = icmp eq i32 %52, 0
br i1 %54, label %55, label %9
55: ; preds = %49, %0
ret i32 0
}