Problems

# Binomial coefficients 5

# Binomial coefficients 5

You are given a positive integer **n <= 40** and non-negative integer **r < 2 ^{n}**.

Find all integers

**k**from

**0**to

**2**such that

^{n}-1**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.

Input example

3 1 0 1 1 3 7

Output example

0 2 0 1 2 1 6