#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 log(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t, n, i, j, k;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    i = log(n) / log(2);
    i++;
    while (i--) {
      if (n & (1 << i))
        printf("1");
      else
        printf("0");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%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     11fd <main+0xcd>
lea    0xe96(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1050 <log@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x2,%edi
call   1050 <log@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
je     11ec <main+0xbc>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11db <main+0xab>
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xb7>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <main+0x6c>
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    115b <main+0x2b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe9e(%rip),%r14
lea    0x8(%rsp),%rbx
jmp    1181 <main+0x51>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
subl   $0x1,0xc(%rsp)
jb     1150 <main+0x20>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%edi
call   1050 <log@plt>
mov    %eax,%ebp
mov    $0x2,%edi
call   1050 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
cmp    $0xffffffff,%eax
je     1170 <main+0x40>
mov    %eax,%ebp
nop
mov    0x8(%rsp),%eax
bt     %ebp,%eax
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jb     11b0 <main+0x80>
jmp    1170 <main+0x40>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\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 %31, label %9
9: ; preds = %0, %26
%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 = call i32 @log(i32 %11)
%13 = call i32 @log(i32 2)
%14 = sdiv i32 %12, %13
%15 = icmp eq i32 %14, -1
br i1 %15, label %26, label %16
16: ; preds = %9, %16
%17 = phi i32 [ %24, %16 ], [ %14, %9 ]
%18 = load i32, i32* %2
%19 = shl nuw i32 1, %17
%20 = and i32 %18, %19
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 48, i32 49
%23 = call i32 @putchar(i32 %22)
%24 = add nsw i32 %17, -1
%25 = icmp eq i32 %17, 0
br i1 %25, label %26, label %16
26: ; preds = %16, %9
%27 = call i32 @putchar(i32 10)
%28 = load i32, i32* %1
%29 = add nsw i32 %28, -1
store i32 %29, i32* %1
%30 = icmp eq i32 %28, 0
br i1 %30, label %31, label %9
31: ; preds = %26, %0
ret i32 0
}