#include "testlib.h"
#include <cstdlib>
#include <cstdio>
#include <vector>

using namespace std;

inline bool check_diff(vector<long long> &a)
{
    for (int i = 1; i < (int) a.size(); i++)
        if (a[i] == a[i - 1])
            return false;
    return true;
}

int main(int argc, char* argv[])
{
    registerGen(argc, argv, 1);

    int n = atoi(argv[1]), k = atoi(argv[2]), T = atoi(argv[3]);
    long long maxw = atoll(argv[4]);
    printf("%d %d %d\n%d\n", n, k, T, rnd.next(k));
    vector<long long> a(n);
    for (int i = 0; i < k; i++)
    {
        do
        {
            for (int j = 0; j < n; j++)
                a[j] = rnd.next(1LL, maxw);
            sort(a.begin(), a.end());
        } 
        while (!check_diff(a));
        for (int j = 0; j < n; j++)
            printf("%lld%c", a[j], "\n "[j < n - 1]);
    }

    return 0;
}
