logo AlgoBeat OnlineJudge
登录 注册

#209354. [ICPC 2020 Shanghai R] Sum of Log

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Given two non-negative integers and , determine the value of

modulo where

  • denotes bitwise AND;
  • equals 1 if is true, otherwise ;
  • equals the maximum integer whose value is no more than .

输入格式

The first line contains one integer denoting the number of test cases.

Each of the following lines contains two integers indicating a test case.

输出格式

For each test case, print one line containing one integer, the answer to the test case.

样例

样例输入 1

3
3 3
19 26
8 17

样例输出 1

14
814
278

数据范围与提示

For the first test case:

  • Two pairs increase the sum by 1:
  • Six pairs increase the sum by 2:

So the answer is .