#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 acos(int);
scalar_t__ floor(int);
int log(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int tc;
  scanf("%d", &tc);
  long long int a;
  while (tc--) {
    scanf("%lld", &a);
    if (a == 0 || a == 1 || a == 2)
      printf("1\n");
    else
      printf("%lld\n",
             (long long int)floor(
                 (log(2 * acos(-1) * a) / 2 + a * (log(a) - 1)) / log(10)) +
                 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     125b <main+0x10b>
lea    0xe77(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11b8 <main+0x68>
cmpq   $0x1,-0x10(%rbp)
je     11b8 <main+0x68>
cmpq   $0x2,-0x10(%rbp)
jne    11cb <main+0x7b>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1256 <main+0x106>
mov    $0xffffffff,%edi
call   1040 <acos@plt>
shl    $0x1,%eax
cltq
imul   -0x10(%rbp),%rax
mov    %eax,%edi
call   1060 <log@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1060 <log@plt>
mov    -0x28(%rbp),%rcx
mov    %eax,%edx
mov    -0x20(%rbp),%rax
sub    $0x1,%edx
movslq %edx,%rdx
imul   %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    $0xa,%edi
call   1060 <log@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
cqto
idiv   %rcx
mov    %eax,%edi
call   1070 <floor@plt>
mov    %rax,%rsi
add    $0x1,%rsi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1171 <main+0x21>
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    0xe8b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     1266 <main+0x106>
lea    0xe70(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xe69(%rip),%r12
jmp    11c7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
subl   $0x1,0xc(%rsp)
jb     1266 <main+0x106>
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpq   $0x2,0x10(%rsp)
jbe    11b0 <main+0x50>
mov    $0xffffffff,%edi
call   1050 <acos@plt>
imul   0x10(%rsp),%eax
lea    (%rax,%rax,1),%edi
call   1070 <log@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%r15
mov    0x10(%rsp),%rbp
mov    %ebp,%edi
call   1070 <log@plt>
add    $0xffffffff,%eax
movslq %eax,%rbx
imul   %rbp,%rbx
add    %r15,%rbx
mov    $0xa,%edi
call   1070 <log@plt>
mov    %eax,%ecx
movslq %eax,%rsi
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1240 <main+0xe0>
mov    %rbx,%rax
cqto
idiv   %rsi
mov    %rax,%rdi
jmp    1248 <main+0xe8>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
call   1080 <floor@plt>
lea    0x1(%rax),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
subl   $0x1,0xc(%rsp)
jae    11c7 <main+0x67>
xor    %eax,%eax
add    $0x18,%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"%lld\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %5
5: ; preds = %46, %0
%6 = load i32, i32* %2
%7 = add nsw i32 %6, -1
store i32 %7, i32* %2
%8 = icmp ne i32 %6, 0
br i1 %8, label %9, label %47
9: ; preds = %5
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %9
%14 = load i64, i64* %3
%15 = icmp eq i64 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i64, i64* %3
%18 = icmp eq i64 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %16, %13, %9
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %46
21: ; preds = %16
%22 = call i32 @acos(i32 -1)
%23 = mul nsw i32 2, %22
%24 = sext i32 %23 to i64
%25 = load i64, i64* %3
%26 = mul nsw i64 %24, %25
%27 = trunc i64 %26 to i32
%28 = call i32 @log(i32 %27)
%29 = sdiv i32 %28, 2
%30 = sext i32 %29 to i64
%31 = load i64, i64* %3
%32 = load i64, i64* %3
%33 = trunc i64 %32 to i32
%34 = call i32 @log(i32 %33)
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = mul nsw i64 %31, %36
%38 = add nsw i64 %30, %37
%39 = call i32 @log(i32 10)
%40 = sext i32 %39 to i64
%41 = sdiv i64 %38, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @floor(i32 %42)
%44 = add nsw i64 %43, 1
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %44)
br label %46
46: ; preds = %21, %19
br label %5
47: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
@str = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = bitcast i64* %2 to i8*
%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 %42, label %9
9: ; preds = %0, %38
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
%12 = icmp ult i64 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %38
15: ; preds = %9
%16 = call i32 @acos(i32 -1)
%17 = shl nsw i32 %16, 1
%18 = load i64, i64* %2
%19 = trunc i64 %18 to i32
%20 = mul i32 %17, %19
%21 = call i32 @log(i32 %20)
%22 = sdiv i32 %21, 2
%23 = sext i32 %22 to i64
%24 = load i64, i64* %2
%25 = trunc i64 %24 to i32
%26 = call i32 @log(i32 %25)
%27 = add nsw i32 %26, -1
%28 = sext i32 %27 to i64
%29 = mul nsw i64 %24, %28
%30 = add nsw i64 %29, %23
%31 = call i32 @log(i32 10)
%32 = sext i32 %31 to i64
%33 = sdiv i64 %30, %32
%34 = trunc i64 %33 to i32
%35 = call i64 @floor(i32 %34)
%36 = add nsw i64 %35, 1
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %36)
br label %38
38: ; preds = %15, %13
%39 = load i32, i32* %1
%40 = add nsw i32 %39, -1
store i32 %40, i32* %1
%41 = icmp eq i32 %39, 0
br i1 %41, label %42, label %9
42: ; preds = %38, %0
ret i32 0
}