#include <bits/stdc++.h>
using namespace std;

bool cnt[600];
vector<int> num;

int main() {
    ios::sync_with_stdio(false), cout.tie(nullptr);
    freopen("meow.in", "w", stdout);
    int T = 10;
    cout << T << endl;
    mt19937 rnd(time(NULL));
    while (T--) {
        int n = 300, m = 150000, k = 599;
        num.clear();
/*
        for (int i = 1; i <= k; i++) cnt[i] = false;
        for (int i = 1; i <= m; i++) {
            int v = rnd() % k + 1;
            num.push_back(v);
            cnt[v] ^= true;
        }
        for (int i = 1; i <= k; i++)
            if (cnt[i]) num.push_back(i);
*/
        m /= 2;
        for (int i = 1; i <= k; i++) cnt[i] = true, num.push_back(i);
        for (int i = 0; i < m;) {
            int l = min((unsigned long)50, rnd() % (m - i) + 1);
            i += l;
            vector<int> cac;
            for (int j = 1; j <= l; j++) {
                int v = rnd() % k + 1;
                cac.push_back(v), cac.push_back(v);
            }
            shuffle(cac.begin(), cac.end(), rnd);
            for (auto i : cac) num.push_back(i);
        }
        for (int i = 1; i <= k; i++)
            if (cnt[i]) num.push_back(i);
        cout << n << ' ' << num.size() << ' ' << k << endl;
        for (auto i : num) cout << i << ' ';
        cout << endl;
    }
    return 0;
}