CodeChef: June Challenge | Bitwise Tuples | BITTUP| Python, Java, C++ Solution

Codechef

View problem on codechef

Chef has two numbers NN and MM. Help Chef to find number of integer NN-tuples (A1,A2,…,AN)(A1,A2,…,AN) such that 0≤A1,A2,…,AN≤2M−10≤A1,A2,…,AN≤2M−1 and A1&A2&…&AN=0A1&A2&…&AN=0, where && denotes the bitwise AND operator.

Since the number of tuples can be large, output it modulo 109+7109+7.

For the work from home Internship Programs : Click here to apply now

Input

  • The first line contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
  • The first and only line of each test case contains two integers NN and MM.

Output

For each test case, output in a single line the answer to the problem modulo 109+7109+7.

Constraints

  • 1≤T≤1051≤T≤105
  • 1≤N,M≤1061≤N,M≤106

Subtasks

Subtask #1 (100 points): original constraints

Sample Input

4
1 2
2 2
4 2
8 4

Sample Output

1
9
225
228250597

Explanation

Test Case 11: The only possible tuple is (0)(0).

Test Case 22: The tuples are (0,0)(0,0), (0,1)(0,1), (0,2)(0,2), (0,3)(0,3), (1,0)(1,0), (2,0)(2,0), (3,0)(3,0), (1,2)(1,2), (2,1)(2,1).

Solution

Due to copyright issues we won't be able to update the solution here immediately. However you can download the code file from our telegram channel. So join our telegram channel for further updates. Keep tracking, the solution will be updated on this website soon.
  • HACKEREARTH IS HIRING FOR INTERN || APPLY NOW
  • INTEL IS HIRING FOR SOFTWARE DEVELOPER INTERN || APPLY Now
  • DATA SCIENCE INTERNSHIP | SONY RESEARCH INDIA || APPLY NOW

Read more posts here

Read more post Here

Leave a Comment

Your email address will not be published. Required fields are marked *

x