#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int n, num, i, j, flag;
  int str[1000];
  while (scanf("%d", &n) != EOF) {
    for (j = 0; j < n; j++) {
      scanf("%d", &num);
      memset(str, 0, sizeof(str));
      i = 499;
      while (num > 0) {
        str[i] = num % 2;
        num /= 2;
        i--;
      }
      flag = 0;
      for (i = 0; i < 500; i++) {
        if (!flag && str[i] == 0)
          continue;
        else {
          flag = 1;
          printf("%d", str[i]);
        }
      }
      if (!flag)
        printf("0");
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
je     1283 <main+0x153>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    127e <main+0x14e>
lea    0xe84(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0xfc0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
movl   $0x1f3,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11db <main+0xab>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0x10(%rbp),%rax
mov    %edx,-0xfc0(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    119f <main+0x6f>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1f4,-0x10(%rbp)
jge    124a <main+0x11a>
cmpl   $0x0,-0x18(%rbp)
jne    1217 <main+0xe7>
movslq -0x10(%rbp),%rax
cmpl   $0x0,-0xfc0(%rbp,%rax,4)
jne    1217 <main+0xe7>
jmp    123c <main+0x10c>
movl   $0x1,-0x18(%rbp)
movslq -0x10(%rbp),%rax
mov    -0xfc0(%rbp,%rax,4),%esi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123c <main+0x10c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e9 <main+0xb9>
cmpl   $0x0,-0x18(%rbp)
jne    1262 <main+0x132>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <main+0x39>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfb8,%rsp
lea    0xea8(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%rax
jne    1182 <main+0x42>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe77(%rip),%rbx
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%r15
jmp    11b9 <main+0x79>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%rax
je     116e <main+0x2e>
cmpl   $0x0,0x8(%rsp)
jle    11a0 <main+0x60>
xor    %r13d,%r13d
jmp    11e5 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
cmp    0x8(%rsp),%r13d
jge    11a0 <main+0x60>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1228 <main+0xe8>
lea    0x7dc(%rsp),%rcx
nop
mov    %eax,%edx
mov    %eax,%esi
and    $0x1,%esi
mov    %esi,(%rcx)
shr    %eax
add    $0xfffffffffffffffc,%rcx
cmp    $0x2,%edx
jae    1210 <main+0xd0>
mov    %eax,0xc(%rsp)
mov    $0x1,%bpl
xor    %r12d,%r12d
jmp    1247 <main+0x107>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
cmp    $0x1f4,%r12
je     11d0 <main+0x90>
mov    %ebp,%eax
mov    0x10(%rsp,%r12,4),%esi
test   %esi,%esi
sete   %bpl
and    %al,%bpl
cmp    $0x1,%bpl
jne    1230 <main+0xf0>
add    $0x1,%r12
cmp    $0x1f4,%r12
jne    1247 <main+0x107>
mov    $0x30,%edi
call   1030 <putchar@plt>
jmp    11d0 <main+0x90>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [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
%7 = alloca [1000 x i32]
store i32 0, i32* %1
br label %8
8: ; preds = %68, %0
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %69
12: ; preds = %8
store i32 0, i32* %5
br label %13
13: ; preds = %65, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %68
17: ; preds = %13
%18 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %7, i64 0, i64 0
%20 = call i32 @memset(i32* %19, i32 0, i32 4000)
store i32 499, i32* %4
br label %21
21: ; preds = %24, %17
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* %3
%26 = srem i32 %25, 2
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x i32], [1000 x i32]* %7, i64 0, i64 %28
store i32 %26, i32* %29
%30 = load i32, i32* %3
%31 = sdiv i32 %30, 2
store i32 %31, i32* %3
%32 = load i32, i32* %4
%33 = add nsw i32 %32, -1
store i32 %33, i32* %4
br label %21
34: ; preds = %21
store i32 0, i32* %6
store i32 0, i32* %4
br label %35
35: ; preds = %55, %34
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 500
br i1 %37, label %38, label %58
38: ; preds = %35
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
br i1 %40, label %48, label %41
41: ; preds = %38
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1000 x i32], [1000 x i32]* %7, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %41
br label %55
48: ; preds = %41, %38
store i32 1, i32* %6
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1000 x i32], [1000 x i32]* %7, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %48
br label %55
55: ; preds = %54, %47
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %35
58: ; preds = %35
%59 = load i32, i32* %6
%60 = icmp ne i32 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %58
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %63
63: ; preds = %61, %58
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %65
65: ; preds = %63
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %13
68: ; preds = %13
br label %8
69: ; preds = %8
ret i32 0
}

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