Binomial coefficients 5
Hard
Execution time limit is 3 seconds
Runtime memory usage limit is 64 megabytes
You are given a positive integer n <= 40 and non-negative integer r < 2^n. Find all integers k from 0 to 2^n-1 such that C(2^n-1,k) mod 2^n = r.
Input
The input file contains T < 400 test cases. The first line of the input file contains the integer T. Each of the following T lines describes one test case and contains the numbers n and r separated by space.
Output
The output file should consist of T lines. Each line should contain the number of the required values of k followed by these values in increasing order for the corresponding test case from the input file. Numbers in the line should be separated by spaces.
Examples
Input #1
Answer #1
Submissions 81
Acceptance rate 2%