#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 */
long long ceil(long long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  int t, rem, i;
  long long int n, x = 4, m, x2 = 1;
  char ans[200];
  scanf("%d", &t);
  while (t--) {
    x2 = 1;
    strcpy(ans, "");
    x = 4;
    scanf("%lld", &n);
    m = n;
    while (m) {
      rem = m % 4;
      switch (rem) {
      case 1:
        strcat(ans, "2");
        break;
      case 2:
        strcat(ans, "3");
        break;
      case 3:
        strcat(ans, "5");
        break;
      case 0:
        strcat(ans, "7");
        break;
      }
      n -= x;
      m = ceil(n / (x * 1.0));
      x *= 4;
    }
    for (i = strlen(ans) - 1; i >= 0; i--)
      printf("%c", ans[i]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x4,-0x20(%rbp)
movq   $0x1,-0x30(%rbp)
lea    0xe8f(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1332 <main+0x1d2>
movq   $0x1,-0x30(%rbp)
lea    -0x100(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1030 <strcpy@plt>
movq   $0x4,-0x20(%rbp)
lea    0xe49(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12db <main+0x17b>
mov    -0x28(%rbp),%rcx
mov    %ecx,%eax
mov    %eax,%edx
add    $0x3,%edx
test   %rcx,%rcx
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x108(%rbp)
sub    $0x3,%rax
ja     1291 <main+0x131>
mov    -0x108(%rbp),%rax
lea    0xddb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x100(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1080 <strcat@plt>
jmp    1291 <main+0x131>
lea    -0x100(%rbp),%rdi
lea    0xdc6(%rip),%rsi
call   1080 <strcat@plt>
jmp    1291 <main+0x131>
lea    -0x100(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   1080 <strcat@plt>
jmp    1291 <main+0x131>
lea    -0x100(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
movsd  0xd4c(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <ceil@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    11e5 <main+0x85>
lea    -0x100(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     131f <main+0x1bf>
movslq -0x10(%rbp),%rax
movsbl -0x100(%rbp,%rax,1),%esi
ff
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    12ed <main+0x18d>
lea    0xd05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1194 <main+0x34>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe88(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    119f <main+0x3f>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe63(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xe51(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xe52(%rip),%rbx
jmp    11d1 <main+0x71>
mov    $0xa,%edi
call   1030 <putchar@plt>
subl   $0x1,0x4(%rsp)
jb     118b <main+0x2b>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     1260 <main+0x100>
mov    $0x4,%ebp
jmp    1234 <main+0xd4>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
sub    %rbp,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rbp,%xmm1
mov    %rax,0x8(%rsp)
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <ceil@plt>
shl    $0x2,%rbp
test   %rax,%rax
je     1260 <main+0x100>
lea    0x3(%rax),%rcx
test   %rax,%rax
cmovns %rax,%rcx
and    $0xfffffffffffffffc,%rcx
sub    %rcx,%rax
test   $0xfffffffc,%eax
jne    1200 <main+0xa0>
movslq (%rbx,%rax,4),%rsi
add    %rbx,%rsi
mov    %r13,%rdi
call   1080 <strcat@plt>
jmp    1200 <main+0xa0>
xchg   %ax,%ax
mov    %r13,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    11c0 <main+0x60>
mov    %eax,%ebp
add    $0x1,%rbp
cs nopw 0x0(%rax,%rax,1)
lea    -0x2(%rbp),%eax
movsbl 0x10(%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     1280 <main+0x120>
jmp    11c0 <main+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [2 x i8] c"2\00"
@.str.4 = [2 x i8] c"3\00"
@.str.5 = [2 x i8] c"5\00"
@.str.6 = [2 x i8] c"7\00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [200 x i8]
store i32 0, i32* %1
store i64 4, i64* %6
store i64 1, i64* %8
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %71, %0
%12 = load i32, i32* %2
%13 = add nsw i32 %12, -1
store i32 %13, i32* %2
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %73
15: ; preds = %11
store i64 1, i64* %8
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i64 4, i64* %6
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %5)
%19 = load i64, i64* %5
store i64 %19, i64* %7
br label %20
20: ; preds = %40, %15
%21 = load i64, i64* %7
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %54
23: ; preds = %20
%24 = load i64, i64* %7
%25 = srem i64 %24, 4
%26 = trunc i64 %25 to i32
store i32 %26, i32* %3
%27 = load i32, i32* %3
switch i32 %27, label %40 [
i32 1, label %28
i32 2, label %31
i32 3, label %34
i32 0, label %37
]
28: ; preds = %23
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %40
31: ; preds = %23
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %40
34: ; preds = %23
%35 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %40
37: ; preds = %23
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %23, %37, %34, %31, %28
%41 = load i64, i64* %6
%42 = load i64, i64* %5
%43 = sub nsw i64 %42, %41
store i64 %43, i64* %5
%44 = load i64, i64* %5
%45 = sitofp i64 %44 to double
%46 = load i64, i64* %6
%47 = sitofp i64 %46 to double
%48 = fmul double %47, 1.000000e+00
%49 = fdiv double %45, %48
%50 = fptosi double %49 to i64
%51 = call i64 @ceil(i64 %50)
store i64 %51, i64* %7
%52 = load i64, i64* %6
%53 = mul nsw i64 %52, 4
store i64 %53, i64* %6
br label %20
54: ; preds = %20
%55 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%56 = call i32 @strlen(i8* %55)
%57 = sub nsw i32 %56, 1
store i32 %57, i32* %4
br label %58
58: ; preds = %68, %54
%59 = load i32, i32* %4
%60 = icmp sge i32 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %61
%69 = load i32, i32* %4
%70 = add nsw i32 %69, -1
store i32 %70, i32* %4
br label %58
71: ; preds = %58
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %11
73: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [2 x i8] c"2\00"
@.str.4 = [2 x i8] c"3\00"
@.str.5 = [2 x i8] c"5\00"
@.str.6 = [2 x i8] c"7\00"
@reltable.main = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.6 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.5 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [200 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %55, label %11
11: ; preds = %0, %50
%12 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %2)
%14 = load i64, i64* %2
%15 = icmp eq i64 %14, 0
br i1 %15, label %36, label %16
16: ; preds = %11, %26
%17 = phi i64 [ %33, %26 ], [ %14, %11 ]
%18 = phi i64 [ %34, %26 ], [ 4, %11 ]
%19 = srem i64 %17, 4
%20 = and i64 %19, 4294967292
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = shl i64 %19, 2
%24 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.main to i8*), i64 %23)
%25 = call i32 @strcat(i8* %6, i8* %24)
br label %26
26: ; preds = %16, %22
%27 = load i64, i64* %2
%28 = sub nsw i64 %27, %18
store i64 %28, i64* %2
%29 = sitofp i64 %28 to double
%30 = sitofp i64 %18 to double
%31 = fdiv double %29, %30
%32 = fptosi double %31 to i64
%33 = call i64 @ceil(i64 %32)
%34 = shl nsw i64 %18, 2
%35 = icmp eq i64 %33, 0
br i1 %35, label %36, label %16
36: ; preds = %26, %11
%37 = call i32 @strlen(i8* %6)
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = zext i32 %37 to i64
br label %41
41: ; preds = %39, %41
%42 = phi i64 [ %40, %39 ], [ %43, %41 ]
%43 = add nsw i64 %42, -1
%44 = and i64 %43, 4294967295
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 @putchar(i32 %47)
%49 = icmp ugt i64 %42, 1
br i1 %49, label %41, label %50
50: ; preds = %41, %36
%51 = call i32 @putchar(i32 10)
%52 = load i32, i32* %1
%53 = add nsw i32 %52, -1
store i32 %53, i32* %1
%54 = icmp eq i32 %52, 0
br i1 %54, label %55, label %11
55: ; preds = %50, %0
ret i32 0
}