Binomial coefficients 5#322

Binomial coefficients 5

3 seconds
64 megabytes
Hard

Given a positive integer n \leq 40 and a non-negative integer r < 2^n, find all integers from to 2^n - 1 for which the following equality holds:

C_{2^n - 1}^k \bmod 2^n = r

Input

The first line contains the number of test cases t~(t < 400). Each of the following lines represents a separate test case and contains two integers and .

Output

For each test case, print in a separate line the number of suitable values of , followed by these values in increasing order.

Examples

Example 1

Loading
Loading