#P88. Special Judge Test 1: Memory Limit Exceeded

Special Judge Test 1: Memory Limit Exceeded

Person in charge

Problem Description

struct S
{
    bool c[5012];
    int dc[5012][2];
    int ts = 1;
    int x;
    void init(int h)
    {
        memset(c, 0, sizeof c);
        memset(dc, 0, sizeof dc);
        c[1] = 0;
        ts = 1;
        x = h;
    }
    void add(int num)
    {
        int now = 1;
        for (int i = 1, j = x; j >= 0; i++, j--)
        {
            bool cc = num & (1 << j);
            int xx = ts + 1;
            if (dc[now][cc]) xx = dc[now][cc];
            if (xx > ts)
            {
                ts++;
                dc[now][cc] = ts;
                c[ts] = cc;
            }
            now = xx;
        }
    }
};

The above code implements a 01 Trie.

This 01 Trie can store any integer in the range [0,2x)[0,2^x) via the add function. After insertion, the value of variable ts reflects the actual space used by this 01 Trie.

Your task is to insert yy integers from [0,2x)[0,2^x) into such a 01 Trie to maximize its actual space usage.

Input Format

Multiple test cases.

The first line contains a positive integer TT, indicating the number of test cases.

Each of the next TT lines contains two positive integers xx and yy.

Output Format

For each test case, output one line containing yy integers from [0,2x)[0,2^x), representing the integers you insert.

Sample

6
1 1
1 2
2 1
2 2
2 3
2 4
1
0 1
0
1 2
3 0 1
2 3 0 1

Sample Explanation

The ts values for the 6 test cases are 2,3,3,5,6,72,3,3,5,6,7 respectively.

Note: The solution is not unique.

Constraints

1T2046,1x10,1y2x.1 \le T \le 2046, 1 \le x \le 10, 1 \le y \le 2^x.