m < n인 두 정수 n과 m이 주어질 때, i = 0부터 m까지 (n XOR i)의 곱을 소수 1,500,000,001로 나눈 나머지를 구한다.
어려움8비트 연산수학정수론조합론아직 제출이 없습니다시간 제한1초메모리 제한512 MBWhen Rikka was a little girl, she met a hard but interesting problem "A good task to defend AK". This problem used some properties of XOR (exclusive OR, denoted by "⊕" as a binary operation).
Time flies, six years have passed. Rikka has become a college student. Today, Rikka recollected this problem, and she suddenly understood that she knows little about XOR. So she wanted to come up with some problems about XOR and try to solve them.
Most of the problems were very simple, except one of them. Soon, Rikka found it too difficult. So she asked you to give her some help.
Here is the problem. Given two integers n and m, calculate ∏_i=0m(n⊕i). The answer may be very large, so just find it modulo 1,500,000,001 (which is a prime number).
The first line contains a single integer t (1≤t≤20), the number of test cases.
Each test case is given on a separate line which contains two integers n and m (1≤m<n≤109).
For each test case, print a single integer: the answer modulo 1,500,000,001.