Sum of Log
题号:NC214900
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

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

输出

复制
14
814
278

说明

For the first test case:
1. Two {(i,j)} pairs increase the sum by 1: {(0, 1), (1, 0)}
2. Six {(i,j)} pairs increase the sum by 2: {(0, 2), (0, 3), (1, 2), (2, 0), (2, 1), (3, 0)}

So the answer is 1\times 2 + 2\times 6 = 14.