#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 */
char ashtonAndString(char *, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t, i;
  scanf("%d", &t);
  char a[100001];
  char *res = malloc(sizeof(char) * t);
  for (i = 0; i < t; i++) {
    memset(a, 0, 100001);
    int k;
    scanf("%s", a);
    scanf("%d", &k);
    res[i] = ashtonAndString(a, k);
  }
  for (i = 0; i < t; i++) {
    printf("%c\n", res[i]);
  }
  free(res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x186b8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121a <main+0xba>
lea    -0x186b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x186a1,%edx
call   1050 <memset@plt>
lea    -0x186b0(%rbp),%rsi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe24(%rip),%rdi
lea    -0x186bc(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0x186b0(%rbp),%rdi
mov    -0x186bc(%rbp),%esi
call   1060 <ashtonAndString@plt>
mov    %al,%dl
mov    -0x186b8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a1 <main+0x41>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1256 <main+0xf6>
mov    -0x186b8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xdc7(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1221 <main+0xc1>
mov    -0x186b8(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x186c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186b8,%rsp
lea    0xe88(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    123b <main+0xdb>
lea    0x10(%rsp),%rbx
lea    0xe5d(%rip),%r15
lea    0xe53(%rip),%r12
lea    0xc(%rsp),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x186a1,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <ashtonAndString@plt>
mov    %al,(%r14,%rbp,1)
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
cmp    %rax,%rbp
jl     11c0 <main+0x60>
test   %eax,%eax
jle    123b <main+0xdb>
xor    %ebp,%ebp
lea    0xdf2(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14,%rbp,1),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
cmp    %rax,%rbp
jl     1220 <main+0xc0>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x186b8,%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 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100001 x i8]
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = mul i64 1, %9
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
store i8* %12, i8** %5
store i32 0, i32* %3
br label %13
13: ; preds = %30, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = getelementptr inbounds [100001 x i8], [100001 x i8]* %4, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 100001)
%20 = getelementptr inbounds [100001 x i8], [100001 x i8]* %4, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%23 = getelementptr inbounds [100001 x i8], [100001 x i8]* %4, i64 0, i64 0
%24 = load i32, i32* %6
%25 = call signext i8 @ashtonAndString(i8* %23, i32 %24)
%26 = load i8*, i8** %5
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
br label %30
30: ; preds = %17
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %13
33: ; preds = %13
store i32 0, i32* %3
br label %34
34: ; preds = %45, %33
%35 = load i32, i32* %3
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %48
38: ; preds = %34
%39 = load i8*, i8** %5
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %43)
br label %45
45: ; preds = %38
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %34
48: ; preds = %34
%49 = load i8*, i8** %5
%50 = call i32 @free(i8* %49)
ret i32 0
}

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