#include "testlib.h"
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using Testcases = std::vector<std::vector<int>>;

using u32 = uint32_t;
constexpr static u32 HASH_BASE = 653;
constexpr static u32 SECRET_SEED = 02'11'2025;
struct Secret {
    std::mt19937 gen;
    u32 hash;

    Secret() : gen(SECRET_SEED), hash(0u) {}

    u32 Protect(u32 x) {
        x ^= gen();
        hash = hash * HASH_BASE + x;
        return x;
    }
};

Testcases GenRandom() {
    const int t = opt<int>("t");
    const int n = opt<int>("n");

    Testcases res;
    for (int i = 0; i < t; ++i) 
        res.push_back(rnd.perm(n, 1));
    return res;
}

Testcases GenOddEven() {
    const int t = opt<int>("t");
    const int n = opt<int>("n");
    Testcases res;
    for (int i = 0; i < t; ++i) {
        vector<int> s = rnd.perm((n-1)/2, 1);
        vector<int> p(n);
        for (int i = 1; i < n; i += 2)
            p[i] = s[i/2];
        for (int i = 1; i <= (n+1)/2; ++i)
            p[2*i-2] = (n-1)/2+i;
        res.push_back(p);
    }
    return res;
}

Testcases GenBitonic() {
    const int t = opt<int>("t");
    const int n = opt<int>("n");
    Testcases res;
    for (int i = 0; i < t; ++i) {
        vector<int> p = rnd.perm(n - 1, 2);
        const int m = (n - 1) / 2;
        sort(p.begin(), p.begin()+m, greater<int>());
        sort(p.begin()+m, p.end());
        p.insert(p.begin()+m, 1);
        res.push_back(p);
    }
    return res;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0), cin.tie(0);
    registerGen(argc, argv, 1);

    function<Testcases()> gen;
    string type = opt<string>("type");
    if (type == "random") gen = &GenRandom;
    if (type == "odd-even") gen = &GenOddEven;
    if (type == "bitonic") gen = &GenBitonic;
    ensuref(!!gen, "Undefined generator");

    auto testcases = gen();
    
    Secret secret;
    println(testcases.size(), opt<int>("q"));
    for (const auto& p : testcases) {
        std::vector<u32> w(p.size());

        std::transform(p.begin(), p.end(), w.begin(), [&](int x) {
            return secret.Protect(static_cast<u32>(x));
        });

        ensure(w.size() % 2 == 1);
        println(w.size());
        println(w);
    }
}