#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 */
scalar_t__ decent_number(int, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t;
  scanf("%d", &t);
  for (int a0 = 0; a0 < t; a0++) {
    int n;
    char *output;
    scanf("%d", &n);
    output = (char *)malloc((n + 1) * sizeof(char));
    if (decent_number(n, output)) {
      printf("%s\n", output);
    } else {
      printf("-1\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e7 <main+0xa7>
lea    0xe87(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <decent_number@plt>
cmp    $0x0,%rax
je     11c6 <main+0x86>
mov    -0x18(%rbp),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <main+0x94>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0x99>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11be <main+0x7e>
xor    %ebp,%ebp
lea    0xe93(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe8a(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%edi
mov    %rax,%rsi
call   1040 <decent_number@plt>
test   %rax,%rax
cmove  %r12,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1180 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [3 x i8] c"-1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = bitcast i32* %2 to i8*
br label %10
9: ; preds = %10, %0
ret i32 0
10: ; preds = %7, %10
%11 = phi i32 [ 0, %7 ], [ %22, %10 ]
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = load i32, i32* %2
%18 = call i64 @decent_number(i32 %17, i8* %16)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), i8* %16
%21 = call i32 @puts(i8* dereferenceable(1) %20)
%22 = add nuw nsw i32 %11, 1
%23 = load i32, i32* %1
%24 = icmp slt i32 %22, %23
br i1 %24, label %10, label %9
}