Need help with codeforces 1787E

#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long

ll used[200005]={};

int main() 
{
    ll T; cin >> T;
    while (T--) {
        ll n, k, x; cin >> n >> k >> x;
        ll Max_bit=0;
        for (ll i=0; i<=31; i++) {
            if (x&(1<<i)) Max_bit=i;
        }
        ll cnt=0; // maximum number of subsequence
        for (ll i=1; i<=n; i++) {
            if (i&(1<<Max_bit)) cnt++;
        }

        if (k>cnt || (cnt-k)%2==1) {
            cout << "NO\n";
            continue;
        }

        cout << "YES\n";
        for (ll i=1; i<=n; i++) {
            if (k==1) break;
            if (used[i]==1) continue;

            if (i==x) {
                cout << "1 " << x << "\n";
                used[i]=1;
            }
            else {
                cout << "2 " << i << ' ' << (i^x) << "\n";
                used[i]=1, used[(i^x)]=1;
            }
            k--;
        }

        ll left=0;
        for (ll i=1; i<=n; i++) {
            if (used[i]==0) left++;
        }
        cout << left << ' ';
        for (ll i=1; i<=n; i++) {
            if (used[i]==0) cout << i << ' ';
        }
        cout << "\n";

        fill(&used[0], &used[n+1], 0);
    }
}

This is the problem statement: Problem - 1787E - Codeforces
I was implementing the problem solution here: TypeDB Forces 2023 (Div. 1 + Div. 2, Rated, Prizes!) Editorial - Codeforces

But my code doesn’t pass the 2nd test case. Please tell me where I messed up or if I didn’t understand the solution correctly. Thanks.