P13551 ももいろの鍵
Background

> 煌めくライトも 落ちる影も
>
> 全て愛していたいから
Description
You are given a non-negative integer $n$. You need to partition the numbers $0, 1, 2, \dots, n$ into several groups such that the bitwise AND of all numbers in each group is $0$.
Your goal is to maximize the number of groups and provide a valid partitioning scheme.
Input Format
**This problem contains multiple test cases in a single test point.**
The first line contains a positive integer $T$, indicating the number of test cases.
For each test case, the input is formatted as follows:
- One line containing a non-negative integer $n$.
Output Format
For each test case, first output a positive integer $ans$, representing the maximum number of groups.
Then, output $ans$ lines. Each line should start with a positive integer $k$, indicating the size of the current group, followed by $k$ integers representing the elements in the group.
If there are multiple optimal partitioning schemes, you may output any of them.
Explanation/Hint
| Subtask | Points | $n \le$ | Special Constraints |
| :-: | :-: | :-: | :-: |
| $1$ | $10$ | $10$ | None |
| $2$ | $10$ | $20$ | None |
| $3$ | $15$ | $10^5$ | $\forall n,\exists k \geq 0,k \in \N, n=2^k-1$ |
| $4$ | $15$ | $100$ | None |
| $5$ | $15$ | $500$ | None |
| $6$ | $35$ | $10^5$ | None |
For all test cases, it is guaranteed that $1 \le T \le 600$, $0 \le n \le 10^5$, and the sum of $n$ across all test cases in a single test point does not exceed $2 \times 10^5$.
Generated by Deepseek V3.