#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned long *, ...);
int main() {
  unsigned long int t = 0, b = 0, true1 = 0, true2 = 0, a = -1;
  scanf("%lu", &t);
  unsigned long int n, k;
  while (t >= 1) {
    b = 0, true1 = 0, true2 = 0, a = -1;
    scanf("%lu%lu", &n, &k);
    b = n;
    if (n % k == 0) {
      printf("pass\n");
      true1 = 1;
    }
    if (true1 == 0) {
      while (a != 0) {
        a = n % 10;
        if (a == k) {
          printf("pass\n");
          true2 = 1;
          break;
        }
        n /= 10;
      }
    }
    if (true1 == 0 && true2 == 0)
      printf("%lu\n", b);
    t--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0xffffffffffffffff,-0x30(%rbp)
ff
lea    0xea5(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpq   $0x1,-0x10(%rbp)
jb     1289 <main+0x169>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0xffffffffffffffff,-0x30(%rbp)
ff
lea    0xe65(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x40(%rbp)
cmp    $0x0,%rdx
jne    11de <main+0xbe>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x1,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1250 <main+0x130>
jmp    11ee <main+0xce>
cmpq   $0x0,-0x30(%rbp)
je     124b <main+0x12b>
mov    -0x38(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    1234 <main+0x114>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x1,-0x28(%rbp)
jmp    124b <main+0x12b>
mov    -0x38(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x38(%rbp)
jmp    11ee <main+0xce>
jmp    1250 <main+0x130>
cmpq   $0x0,-0x20(%rbp)
jne    1278 <main+0x158>
cmpq   $0x0,-0x28(%rbp)
jne    1278 <main+0x158>
mov    -0x18(%rbp),%rsi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1169 <main+0x49>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,(%rsp)
lea    0xeb6(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpq   $0x0,(%rsp)
je     1233 <main+0x103>
lea    0xe97(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r13
lea    0xe92(%rip),%r12
movabs $0xcccccccccccccccd,%rbp
cc cc cc
jmp    11a3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
addq   $0xffffffffffffffff,(%rsp)
je     1233 <main+0x103>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rbx
mov    %rsi,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11e0 <main+0xb0>
mov    %rsi,%rax
xor    %edx,%edx
div    %rbx
mov    %rdx,%rcx
jmp    11e8 <main+0xb8>
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%ecx
mov    %rsi,%rdx
test   %rcx,%rcx
je     1190 <main+0x60>
mov    %rdx,%rdi
mov    %rdx,%rax
mul    %rbp
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
sub    %rax,%rdi
cmp    %rbx,%rdi
je     1190 <main+0x60>
mov    %rdx,0x8(%rsp)
test   %rdi,%rdi
jne    11f0 <main+0xc0>
test   %rcx,%rcx
je     1198 <main+0x68>
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x68>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [7 x i8] c"%lu%lu\00"
@.str.2 = [6 x i8] c"pass\0A\00"
@.str.3 = [5 x i8] c"%lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
store i64 -1, i64* %6
%9 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %10
10: ; preds = %50, %0
%11 = load i64, i64* %2
%12 = icmp uge i64 %11, 1
br i1 %12, label %13, label %53
13: ; preds = %10
store i64 0, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
store i64 -1, i64* %6
%14 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %7, i64* %8)
%15 = load i64, i64* %7
store i64 %15, i64* %3
%16 = load i64, i64* %7
%17 = load i64, i64* %8
%18 = urem i64 %16, %17
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i64 1, i64* %4
br label %22
22: ; preds = %20, %13
%23 = load i64, i64* %4
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %41
25: ; preds = %22
br label %26
26: ; preds = %37, %25
%27 = load i64, i64* %6
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = load i64, i64* %7
%31 = urem i64 %30, 10
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = load i64, i64* %8
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i64 1, i64* %5
br label %40
37: ; preds = %29
%38 = load i64, i64* %7
%39 = udiv i64 %38, 10
store i64 %39, i64* %7
br label %26
40: ; preds = %35, %26
br label %41
41: ; preds = %40, %22
%42 = load i64, i64* %4
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i64, i64* %5
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i64, i64* %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %48)
br label %50
50: ; preds = %47, %44, %41
%51 = load i64, i64* %2
%52 = add i64 %51, -1
store i64 %52, i64* %2
br label %10
53: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [7 x i8] c"%lu%lu\00"
@.str.3 = [5 x i8] c"%lu\0A\00"
@str.4 = [5 x i8] c"pass\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%5 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%6 = bitcast i64* %2 to i8*
%7 = bitcast i64* %3 to i8*
%8 = load i64, i64* %1
%9 = icmp eq i64 %8, 0
br i1 %9, label %34, label %10
10: ; preds = %0, %30
%11 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%12 = load i64, i64* %2
%13 = load i64, i64* %3
%14 = urem i64 %12, %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0))
br label %30
18: ; preds = %10, %25
%19 = phi i64 [ %21, %25 ], [ %12, %10 ]
%20 = urem i64 %19, 10
%21 = udiv i64 %19, 10
%22 = icmp eq i64 %20, %13
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0))
br label %30
25: ; preds = %18
store i64 %21, i64* %2
%26 = icmp eq i64 %20, 0
br i1 %26, label %27, label %18
27: ; preds = %25
br i1 %15, label %30, label %28
28: ; preds = %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %12)
br label %30
30: ; preds = %16, %23, %28, %27
%31 = load i64, i64* %1
%32 = add i64 %31, -1
store i64 %32, i64* %1
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %10
34: ; preds = %30, %0
ret i32 0
}