#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*/ ceil(scalar_t__);
scalar_t__ log2(double);
unsigned long long pow(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t, i;
  double logn;
  unsigned long long int tot, times, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%llu", &n);
    tot = (pow(2, ceil(log2(n * 1.0))));
    printf("%llu ", tot);
    if (n == tot) {
      printf("0\n");
    } else {
      double x = tot / 2;
      while ((unsigned long long int)n % (unsigned long long int)x != 0)
        x /= 2;
      times = (unsigned long long int)(((log2(tot) - log2(x))));
      printf("%llu\n", times);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     12e3 <main+0x193>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
lea    -0x30(%rbp),%rsi
call   1060 <scanf@plt>
movaps 0xe82(%rip),%xmm1
movq   -0x30(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe81(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe3a(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <log2@plt>
mov    %rax,%rdi
call   1040 <ceil@plt>
mov    %eax,%esi
mov    $0x2,%edi
call   1070 <pow@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    121a <main+0xca>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12de <main+0x18e>
mov    -0x20(%rbp),%rax
shr    %rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movsd  -0x38(%rbp),%xmm0
movsd  0xdcc(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rdx
cvttsd2si %xmm0,%rcx
mov    %rcx,%rsi
sar    $0x3f,%rsi
and    %rsi,%rdx
or     %rdx,%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
je     1284 <main+0x134>
movsd  -0x38(%rbp),%xmm0
movsd  0xd9a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    122b <main+0xdb>
movaps 0xd95(%rip),%xmm1
movq   -0x20(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd94(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <log2@plt>
mov    %rax,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <log2@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1171 <main+0x21>
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    $0x28,%rsp
lea    0xebb(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
subl   $0x1,0x4(%rsp)
jb     132c <main+0x1cc>
lea    0xea0(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe99(%rip),%rbx
lea    0xe9e(%rip),%r12
lea    0xe91(%rip),%r13
jmp    11c3 <main+0x63>
nop
mov    %r12,%rdi
call   1040 <puts@plt>
subl   $0x1,0x4(%rsp)
jb     132c <main+0x1cc>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsd  0x8(%rsp),%xmm1
unpcklps 0xe23(%rip),%xmm1
subpd  0xe2b(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
call   1030 <log2@plt>
mov    %rax,%rdi
call   1050 <ceil@plt>
mov    $0x2,%edi
mov    %eax,%esi
call   1080 <pow@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%rcx
cmp    %rbp,%rcx
je     11b0 <main+0x50>
mov    %rbp,%rax
shr    %rax
xorps  %xmm3,%xmm3
cvtsi2sd %rax,%xmm3
cvttsd2si %xmm3,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movapd %xmm3,%xmm0
movsd  0xdd6(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rsi
and    %rdx,%rsi
or     %rax,%rsi
mov    %rcx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     126f <main+0x10f>
mov    %rcx,%rax
xor    %edx,%edx
div    %rsi
jmp    1275 <main+0x115>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
movsd  0xdab(%rip),%xmm2
test   %rdx,%rdx
jne    129d <main+0x13d>
jmp    12d7 <main+0x177>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rcx,%rax
xor    %edx,%edx
div    %rsi
test   %rdx,%rdx
je     12d7 <main+0x177>
mulsd  %xmm2,%xmm3
cvttsd2si %xmm3,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rsi
and    %rdx,%rsi
or     %rax,%rsi
mov    %rcx,%rax
or     %rsi,%rax
shr    $0x20,%rax
jne    1290 <main+0x130>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
test   %rdx,%rdx
jne    129d <main+0x13d>
movapd %xmm3,0x10(%rsp)
movq   %rbp,%xmm1
punpckldq 0xd16(%rip),%xmm1
subpd  0xd1e(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
call   1030 <log2@plt>
mov    %rax,%rbp
movapd 0x10(%rsp),%xmm0
call   1030 <log2@plt>
sub    %rax,%rbp
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
subl   $0x1,0x4(%rsp)
jae    11c3 <main+0x63>
xor    %eax,%eax
add    $0x28,%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"%llu\00"
@.str.2 = [6 x i8] c"%llu \00"
@.str.3 = [3 x i8] c"0\0A\00"
@.str.4 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %51, %0
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %52
14: ; preds = %10
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %7)
%16 = load i64, i64* %7
%17 = uitofp i64 %16 to double
%18 = fmul double %17, 1.000000e+00
%19 = call i64 @log2(double %18)
%20 = call i32 @ceil(i64 %19)
%21 = call i64 @pow(i32 2, i32 %20)
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %22)
%24 = load i64, i64* %7
%25 = load i64, i64* %5
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %14
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %51
29: ; preds = %14
%30 = load i64, i64* %5
%31 = udiv i64 %30, 2
%32 = uitofp i64 %31 to double
store double %32, double* %8
br label %33
33: ; preds = %39, %29
%34 = load i64, i64* %7
%35 = load double, double* %8
%36 = fptoui double %35 to i64
%37 = urem i64 %34, %36
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load double, double* %8
%41 = fdiv double %40, 2.000000e+00
store double %41, double* %8
br label %33
42: ; preds = %33
%43 = load i64, i64* %5
%44 = uitofp i64 %43 to double
%45 = call i64 @log2(double %44)
%46 = load double, double* %8
%47 = call i64 @log2(double %46)
%48 = sub nsw i64 %45, %47
store i64 %48, i64* %6
%49 = load i64, i64* %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %49)
br label %51
51: ; preds = %42, %27
br label %10
52: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%llu\00"
@.str.2 = [6 x i8] c"%llu \00"
@.str.4 = [6 x i8] c"%llu\0A\00"
@str = [2 x i8] c"0\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 %44, label %9
9: ; preds = %0, %40
%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 = uitofp i64 %11 to double
%13 = call i64 @log2(double %12)
%14 = call i32 @ceil(i64 %13)
%15 = call i64 @pow(i32 2, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %15)
%17 = load i64, i64* %2
%18 = icmp eq i64 %17, %15
br i1 %18, label %19, label %21
19: ; preds = %9
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %40
21: ; preds = %9
%22 = lshr i64 %15, 1
%23 = uitofp i64 %22 to double
%24 = fptoui double %23 to i64
%25 = urem i64 %17, %24
%26 = icmp eq i64 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %21, %27
%28 = phi double [ %29, %27 ], [ %23, %21 ]
%29 = fmul double %28, 5.000000e-01
%30 = fptoui double %29 to i64
%31 = urem i64 %17, %30
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %27
33: ; preds = %27, %21
%34 = phi double [ %23, %21 ], [ %29, %27 ]
%35 = uitofp i64 %15 to double
%36 = call i64 @log2(double %35)
%37 = call i64 @log2(double %34)
%38 = sub nsw i64 %36, %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %38)
br label %40
40: ; preds = %33, %19
%41 = load i32, i32* %1
%42 = add nsw i32 %41, -1
store i32 %42, i32* %1
%43 = icmp eq i32 %41, 0
br i1 %43, label %44, label %9
44: ; preds = %40, %0
ret i32 0
}