#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t, n, r = 0;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    if (n == 3) {
      printf("3\n");
      continue;
    }
    for (r = 0; n != 3 && n != 2; n = (n + 1) / 2)
      r++;
    if (n == 2)
      printf("%d\n", r + 2);
    else
      printf("%d\n", r + 3);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1212 <main+0xf2>
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3,-0xc(%rbp)
jne    1187 <main+0x67>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1146 <main+0x26>
movl   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x3,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a7 <main+0x87>
cmpl   $0x2,-0xc(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11b7 <main+0x97>
jmp    11d6 <main+0xb6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    118e <main+0x6e>
cmpl   $0x2,-0xc(%rbp)
jne    11f9 <main+0xd9>
mov    -0x10(%rbp),%esi
add    $0x2,%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <main+0xed>
mov    -0x10(%rbp),%esi
add    $0x3,%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1146 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
subl   $0x1,0x4(%rsp)
jb     11ee <main+0xbe>
lea    0xea5(%rip),%r14
mov    %rsp,%rbx
lea    0xea2(%rip),%r15
lea    0xe97(%rip),%r12
jmp    117f <main+0x4f>
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
subl   $0x1,0x4(%rsp)
jb     11ee <main+0xbe>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x3,%eax
je     1170 <main+0x40>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
xor    %esi,%esi
cmp    $0x2,%ecx
je     11da <main+0xaa>
mov    $0x3,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%ecx
lea    0x1(%rcx),%eax
shr    $0x1f,%eax
add    %ecx,%eax
add    $0x1,%eax
sar    %eax
mov    %eax,%edx
and    $0xfffffffe,%edx
add    $0x1,%esi
cmp    $0x2,%edx
jne    11b0 <main+0x80>
mov    %eax,(%rsp)
add    $0xfffffffd,%ecx
cmp    $0x1,%ecx
ja     11dd <main+0xad>
add    $0xfffffffd,%esi
add    $0x2,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
subl   $0x1,0x4(%rsp)
jae    117f <main+0x4f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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