#include "testlib.h"
#include <cassert>

using namespace std;

const int MAXN[5] = {3, 12, 18, 24, 26}, MAXK[5] = {3, 14, 26, 2, 26};
const long long MAXW[5] = {4, 1000000000, 1000000000, 1000000000, 1000000000000000LL};

void validate(int group)
{
    int n = inf.readInt(1, MAXN[group], "n");
    inf.readSpace();
    int k = inf.readInt(1, MAXK[group], "k");
    inf.readSpace();
    int exp_T = (group <= 1 ? 540000 : k);
    inf.readInt(exp_T, exp_T, "T");
    inf.readEoln();

    inf.readInt(0, k - 1, "set_id");
    inf.readEoln();

    for (int i = 0; i < k; i++)
    {
        long long prv = 0;
        for (int j = 0; j < n; j++)
        {
            long long a = inf.readLong(1, MAXW[group]);
            ensuref(a > prv, "in %d-th set: a_%d <= a_%d", i, j, j - 1);
            prv = a;
            if (j < n - 1)
                inf.readSpace();
            else
                inf.readEoln();
        }
    }

    inf.readEof();
}

int main(int argc, char **argv)
{
    assert(argc);
    registerValidation();
    int group = atoi(argv[1]);
    validate(group);
    
    return 0;
}

