#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);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int i, j, c, len, num1, num2, temp, t, res;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &num1, &num2);
    res = num1;
    for (i = num1 + 1; i <= num2; i++) {
      res = res & i;
      if (!res)
        break;
    }
    printf("%d\n", res);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
je     11c5 <main+0xa5>
lea    0xea4(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11b1 <main+0x91>
mov    -0x28(%rbp),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    119e <main+0x7e>
jmp    11b1 <main+0x91>
jmp    11a3 <main+0x83>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117a <main+0x5a>
mov    -0x28(%rbp),%esi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <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    $0x18,%rsp
lea    0xed1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1153 <main+0x33>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xea6(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe9b(%rip),%rbx
jmp    117f <main+0x5f>
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1145 <main+0x25>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%eax
cmp    %eax,%esi
cmovg  %esi,%eax
neg    %eax
lea    0x1(%rsi),%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rax,%rcx,1),%edx
cmp    $0x1,%edx
je     1170 <main+0x50>
lea    0x1(%rcx),%edx
and    %ecx,%esi
mov    %edx,%ecx
jne    11b0 <main+0x90>
xor    %esi,%esi
jmp    1170 <main+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %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 i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
br label %12
12: ; preds = %36, %0
%13 = load i32, i32* %9
%14 = add nsw i32 %13, -1
store i32 %14, i32* %9
%15 = icmp ne i32 %13, 0
br i1 %15, label %16, label %39
16: ; preds = %12
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%18 = load i32, i32* %6
store i32 %18, i32* %10
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %21
21: ; preds = %33, %16
%22 = load i32, i32* %2
%23 = load i32, i32* %7
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i32, i32* %10
%27 = load i32, i32* %2
%28 = and i32 %26, %27
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %25
br label %36
32: ; preds = %25
br label %33
33: ; preds = %32
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %21
36: ; preds = %31, %21
%37 = load i32, i32* %10
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %12
39: ; preds = %12
ret i32 0
}

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