#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 *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int T;
  scanf("%d", &T);
  for (int i = 0; i < T; i++) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    long long result, temp;
    temp = a ^ b;
    temp |= temp >> 1;
    temp |= temp >> 2;
    temp |= temp >> 4;
    temp |= temp >> 8;
    temp |= temp >> 16;
    temp |= temp >> 32;
    result = a & ~temp;
    printf("%lld\n", result);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1207 <main+0xe7>
lea    0xea8(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
xor    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x1,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x2,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x4,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x8,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x10,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x20,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
xor    $0xffffffffffffffff,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <main+0x28>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11df <main+0xbf>
lea    0xeb2(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xeab(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x18(%rsp),%rax
mov    0x10(%rsp),%rcx
xor    %rax,%rcx
mov    %rcx,%rdx
sar    %rdx
or     %rcx,%rdx
mov    %rdx,%rcx
sar    $0x2,%rcx
or     %rdx,%rcx
mov    %rcx,%rdx
sar    $0x4,%rdx
or     %rcx,%rdx
mov    %rdx,%rcx
sar    $0x8,%rcx
or     %rdx,%rcx
mov    %rcx,%rdx
sar    $0x10,%rdx
or     %rcx,%rdx
mov    %rdx,%rsi
sar    $0x20,%rsi
or     %rdx,%rsi
not    %rsi
and    %rax,%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1170 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%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 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = bitcast i64* %2 to i8*
%10 = bitcast i64* %3 to i8*
br label %12
11: ; preds = %12, %0
ret i32 0
12: ; preds = %8, %12
%13 = phi i32 [ 0, %8 ], [ %33, %12 ]
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%15 = load i64, i64* %2
%16 = load i64, i64* %3
%17 = xor i64 %16, %15
%18 = ashr i64 %17, 1
%19 = or i64 %18, %17
%20 = ashr i64 %19, 2
%21 = or i64 %20, %19
%22 = ashr i64 %21, 4
%23 = or i64 %22, %21
%24 = ashr i64 %23, 8
%25 = or i64 %24, %23
%26 = ashr i64 %25, 16
%27 = or i64 %26, %25
%28 = ashr i64 %27, 32
%29 = or i64 %28, %27
%30 = xor i64 %29, -1
%31 = and i64 %15, %30
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %31)
%33 = add nuw nsw i32 %13, 1
%34 = load i32, i32* %1
%35 = icmp slt i32 %33, %34
br i1 %35, label %12, label %11
}