{$r+,q+,o-}
type
    int = longint;

const
    n = 100;
    m = 50;
    k = 137;
    x = 20;
    y = 5;
    MAXN = 100;

var
    s: array [1..MAXN, 1..6] of int;
    p: array [1..MAXN] of int;
    tmp: array [1..MAXN] of int;

procedure shuffle;
var
    i, j, k: int;

begin
    for i := 1 to n do begin
        j := random(i) + 1;
        p[i] := p[j];
        p[j] := i;
    end;

    for j := 1 to 6 do begin
        for i := 1 to n do begin
            tmp[i] := s[p[i]][j];
        end;
        for i := 1 to n do begin
            s[i][j] := tmp[i];
        end;
    end;

    for i := 1 to n do begin
        for j := 1 to 3 do begin
            k := random(j) + 1;
            p[j] := p[k];
            p[k] := j;
        end;
        for j := 1 to 3 do begin
            tmp[j] := s[i][p[j]];
        end;
        for j := 1 to 3 do begin
            s[i][j] := tmp[j];
        end;
        for j := 1 to 3 do begin
            tmp[j] := s[i][p[j] + 3];
        end;
        for j := 1 to 3 do begin
            s[i][j + 3] := tmp[j];
        end;
    end;
end;

procedure printTest;
var
    i: int;

begin
    writeln(n, ' ', m + y, ' ', k);
    for i := 1 to n do begin
        writeln(s[i][1], ' ', s[i][2], ' ', s[i][3], ' ', s[i][4], ' ', s[i][5], ' ', s[i][6]);
    end;
end;

var
    i: int;

begin
    randseed := 239131;
    for i := 1 to m do begin
        s[i][1] := random(100);
        s[i][2] := random(100);
        s[i][3] := random(100);
        s[i][4] := 50000 - random(1000);
        s[i][5] := 500 + random(100);
        s[i][6] := 500 + random(100);
    end;

    for i := 1 to x do begin
        s[i + m][1] := random(100);
        s[i + m][2] := random(100);
        s[i + m][3] := random(100);
        s[i + m][4] := 51000 - random(1000);
        s[i + m][5] := 500 + random(100);
        s[i + m][6] := 500 + random(100);
    end;

    for i := m + x + 1 to n - y do begin
        s[i][1] := random(100);
        s[i][2] := random(100);
        s[i][3] := random(100);
        s[i][4] := random(100);
        s[i][5] := random(100);
        s[i][6] := random(100);
    end;

    for i := n - y + 1 to n do begin
        s[i][1] := random(10);
        s[i][2] := random(10);
        s[i][3] := random(10);
        s[i][4] := 80000 - random(1000);
        s[i][5] := 10 + random(10);
        s[i][6] := random(10);
    end;
    shuffle();
    printTest();
end.
