#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int p, i;
    char n[20];
    scanf("%s %d", n, &p);
    for (i = 0; i < p; i++) {
      n[i] = '9';
    }
    printf("%d\n", atoi(n));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11c1 <main+0x91>
lea    -0x30(%rbp),%rsi
lea    0xe90(%rip),%rdi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a5 <main+0x75>
movslq -0x10(%rbp),%rax
movb   $0x39,-0x30(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1182 <main+0x52>
lea    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xeb1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0x8(%rsp)
jae    1173 <main+0x33>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe86(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r15
lea    0xe7b(%rip),%r12
jmp    11a9 <main+0x69>
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
subl   $0x1,0x8(%rsp)
jb     1165 <main+0x25>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    1190 <main+0x50>
mov    %rbx,%rdi
mov    $0x39,%esi
call   1040 <memset@plt>
jmp    1190 <main+0x50>

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

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