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

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
int rng(int l, int r) { return rnd() % (r - l + 1) + l; }

template<typename T>
inline void read(T &x) {
    x = 0; char ch = getchar();
    bool f = 0;
    while (!isdigit(ch)) f |= ch == '-', ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    if (f) x = -x;
}
template<typename T>
inline void write(T x, char c) {
    if (x == 0) {
        putchar('0'), putchar(c);
        return;
    }
    static int stk[20];
    int top = 0;
    while (x) stk[++top] = x % 10, x /= 10;
    while (top) putchar('0' + stk[top--]);
    putchar(c);
}

int main() {
    freopen("meow.in", "w", stdout);

    int T = 1000;
    write(T, '\n');
    while (T--) {
        int n = rng(1, 5), k = 2 * n - 1;
        int m = k * 2 * rng(1, 1000);
        printf("%d %d %d\n", n, m, k);
        for (int i = 1; i <= m / k; ++i) {
            vector<int> a(k);
            iota(a.begin(), a.end(), 1);
            shuffle(a.begin(), a.end(), rnd);
            for (auto x : a) write(x, ' ');
        }
        putchar('\n');
    }

    return 0;
}