#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int P = 37;
int inv[P];

int lines[1407][2] = {{1,2},{1,38},{1,39},{1,40},{1,41},{1,42},{1,43},{1,44},{1,45},{1,46},{1,47},{1,48},{1,49},{1,50},{1,51},{1,52},{1,53},{1,54},{1,55},{1,56},{1,57},{1,58},{1,59},{1,60},{1,61},{1,62},{1,63},{1,64},{1,65},{1,66},{1,67},{1,68},{1,69},{1,70},{1,71},{1,72},{1,73},{1,74},{2,38},{2,39},{2,40},{2,41},{2,42},{2,43},{2,44},{2,45},{2,46},{2,47},{2,48},{2,49},{2,50},{2,51},{2,52},{2,53},{2,54},{2,55},{2,56},{2,57},{2,58},{2,59},{2,60},{2,61},{2,62},{2,63},{2,64},{2,65},{2,66},{2,67},{2,68},{2,69},{2,70},{2,71},{2,72},{2,73},{2,74},{3,38},{3,39},{3,40},{3,41},{3,42},{3,43},{3,44},{3,45},{3,46},{3,47},{3,48},{3,49},{3,50},{3,51},{3,52},{3,53},{3,54},{3,55},{3,56},{3,57},{3,58},{3,59},{3,60},{3,61},{3,62},{3,63},{3,64},{3,65},{3,66},{3,67},{3,68},{3,69},{3,70},{3,71},{3,72},{3,73},{3,74},{4,38},{4,39},{4,40},{4,41},{4,42},{4,43},{4,44},{4,45},{4,46},{4,47},{4,48},{4,49},{4,50},{4,51},{4,52},{4,53},{4,54},{4,55},{4,56},{4,57},{4,58},{4,59},{4,60},{4,61},{4,62},{4,63},{4,64},{4,65},{4,66},{4,67},{4,68},{4,69},{4,70},{4,71},{4,72},{4,73},{4,74},{5,38},{5,39},{5,40},{5,41},{5,42},{5,43},{5,44},{5,45},{5,46},{5,47},{5,48},{5,49},{5,50},{5,51},{5,52},{5,53},{5,54},{5,55},{5,56},{5,57},{5,58},{5,59},{5,60},{5,61},{5,62},{5,63},{5,64},{5,65},{5,66},{5,67},{5,68},{5,69},{5,70},{5,71},{5,72},{5,73},{5,74},{6,38},{6,39},{6,40},{6,41},{6,42},{6,43},{6,44},{6,45},{6,46},{6,47},{6,48},{6,49},{6,50},{6,51},{6,52},{6,53},{6,54},{6,55},{6,56},{6,57},{6,58},{6,59},{6,60},{6,61},{6,62},{6,63},{6,64},{6,65},{6,66},{6,67},{6,68},{6,69},{6,70},{6,71},{6,72},{6,73},{6,74},{7,38},{7,39},{7,40},{7,41},{7,42},{7,43},{7,44},{7,45},{7,46},{7,47},{7,48},{7,49},{7,50},{7,51},{7,52},{7,53},{7,54},{7,55},{7,56},{7,57},{7,58},{7,59},{7,60},{7,61},{7,62},{7,63},{7,64},{7,65},{7,66},{7,67},{7,68},{7,69},{7,70},{7,71},{7,72},{7,73},{7,74},{8,38},{8,39},{8,40},{8,41},{8,42},{8,43},{8,44},{8,45},{8,46},{8,47},{8,48},{8,49},{8,50},{8,51},{8,52},{8,53},{8,54},{8,55},{8,56},{8,57},{8,58},{8,59},{8,60},{8,61},{8,62},{8,63},{8,64},{8,65},{8,66},{8,67},{8,68},{8,69},{8,70},{8,71},{8,72},{8,73},{8,74},{9,38},{9,39},{9,40},{9,41},{9,42},{9,43},{9,44},{9,45},{9,46},{9,47},{9,48},{9,49},{9,50},{9,51},{9,52},{9,53},{9,54},{9,55},{9,56},{9,57},{9,58},{9,59},{9,60},{9,61},{9,62},{9,63},{9,64},{9,65},{9,66},{9,67},{9,68},{9,69},{9,70},{9,71},{9,72},{9,73},{9,74},{10,38},{10,39},{10,40},{10,41},{10,42},{10,43},{10,44},{10,45},{10,46},{10,47},{10,48},{10,49},{10,50},{10,51},{10,52},{10,53},{10,54},{10,55},{10,56},{10,57},{10,58},{10,59},{10,60},{10,61},{10,62},{10,63},{10,64},{10,65},{10,66},{10,67},{10,68},{10,69},{10,70},{10,71},{10,72},{10,73},{10,74},{11,38},{11,39},{11,40},{11,41},{11,42},{11,43},{11,44},{11,45},{11,46},{11,47},{11,48},{11,49},{11,50},{11,51},{11,52},{11,53},{11,54},{11,55},{11,56},{11,57},{11,58},{11,59},{11,60},{11,61},{11,62},{11,63},{11,64},{11,65},{11,66},{11,67},{11,68},{11,69},{11,70},{11,71},{11,72},{11,73},{11,74},{12,38},{12,39},{12,40},{12,41},{12,42},{12,43},{12,44},{12,45},{12,46},{12,47},{12,48},{12,49},{12,50},{12,51},{12,52},{12,53},{12,54},{12,55},{12,56},{12,57},{12,58},{12,59},{12,60},{12,61},{12,62},{12,63},{12,64},{12,65},{12,66},{12,67},{12,68},{12,69},{12,70},{12,71},{12,72},{12,73},{12,74},{13,38},{13,39},{13,40},{13,41},{13,42},{13,43},{13,44},{13,45},{13,46},{13,47},{13,48},{13,49},{13,50},{13,51},{13,52},{13,53},{13,54},{13,55},{13,56},{13,57},{13,58},{13,59},{13,60},{13,61},{13,62},{13,63},{13,64},{13,65},{13,66},{13,67},{13,68},{13,69},{13,70},{13,71},{13,72},{13,73},{13,74},{14,38},{14,39},{14,40},{14,41},{14,42},{14,43},{14,44},{14,45},{14,46},{14,47},{14,48},{14,49},{14,50},{14,51},{14,52},{14,53},{14,54},{14,55},{14,56},{14,57},{14,58},{14,59},{14,60},{14,61},{14,62},{14,63},{14,64},{14,65},{14,66},{14,67},{14,68},{14,69},{14,70},{14,71},{14,72},{14,73},{14,74},{15,38},{15,39},{15,40},{15,41},{15,42},{15,43},{15,44},{15,45},{15,46},{15,47},{15,48},{15,49},{15,50},{15,51},{15,52},{15,53},{15,54},{15,55},{15,56},{15,57},{15,58},{15,59},{15,60},{15,61},{15,62},{15,63},{15,64},{15,65},{15,66},{15,67},{15,68},{15,69},{15,70},{15,71},{15,72},{15,73},{15,74},{16,38},{16,39},{16,40},{16,41},{16,42},{16,43},{16,44},{16,45},{16,46},{16,47},{16,48},{16,49},{16,50},{16,51},{16,52},{16,53},{16,54},{16,55},{16,56},{16,57},{16,58},{16,59},{16,60},{16,61},{16,62},{16,63},{16,64},{16,65},{16,66},{16,67},{16,68},{16,69},{16,70},{16,71},{16,72},{16,73},{16,74},{17,38},{17,39},{17,40},{17,41},{17,42},{17,43},{17,44},{17,45},{17,46},{17,47},{17,48},{17,49},{17,50},{17,51},{17,52},{17,53},{17,54},{17,55},{17,56},{17,57},{17,58},{17,59},{17,60},{17,61},{17,62},{17,63},{17,64},{17,65},{17,66},{17,67},{17,68},{17,69},{17,70},{17,71},{17,72},{17,73},{17,74},{18,38},{18,39},{18,40},{18,41},{18,42},{18,43},{18,44},{18,45},{18,46},{18,47},{18,48},{18,49},{18,50},{18,51},{18,52},{18,53},{18,54},{18,55},{18,56},{18,57},{18,58},{18,59},{18,60},{18,61},{18,62},{18,63},{18,64},{18,65},{18,66},{18,67},{18,68},{18,69},{18,70},{18,71},{18,72},{18,73},{18,74},{19,38},{19,39},{19,40},{19,41},{19,42},{19,43},{19,44},{19,45},{19,46},{19,47},{19,48},{19,49},{19,50},{19,51},{19,52},{19,53},{19,54},{19,55},{19,56},{19,57},{19,58},{19,59},{19,60},{19,61},{19,62},{19,63},{19,64},{19,65},{19,66},{19,67},{19,68},{19,69},{19,70},{19,71},{19,72},{19,73},{19,74},{20,38},{20,39},{20,40},{20,41},{20,42},{20,43},{20,44},{20,45},{20,46},{20,47},{20,48},{20,49},{20,50},{20,51},{20,52},{20,53},{20,54},{20,55},{20,56},{20,57},{20,58},{20,59},{20,60},{20,61},{20,62},{20,63},{20,64},{20,65},{20,66},{20,67},{20,68},{20,69},{20,70},{20,71},{20,72},{20,73},{20,74},{21,38},{21,39},{21,40},{21,41},{21,42},{21,43},{21,44},{21,45},{21,46},{21,47},{21,48},{21,49},{21,50},{21,51},{21,52},{21,53},{21,54},{21,55},{21,56},{21,57},{21,58},{21,59},{21,60},{21,61},{21,62},{21,63},{21,64},{21,65},{21,66},{21,67},{21,68},{21,69},{21,70},{21,71},{21,72},{21,73},{21,74},{22,38},{22,39},{22,40},{22,41},{22,42},{22,43},{22,44},{22,45},{22,46},{22,47},{22,48},{22,49},{22,50},{22,51},{22,52},{22,53},{22,54},{22,55},{22,56},{22,57},{22,58},{22,59},{22,60},{22,61},{22,62},{22,63},{22,64},{22,65},{22,66},{22,67},{22,68},{22,69},{22,70},{22,71},{22,72},{22,73},{22,74},{23,38},{23,39},{23,40},{23,41},{23,42},{23,43},{23,44},{23,45},{23,46},{23,47},{23,48},{23,49},{23,50},{23,51},{23,52},{23,53},{23,54},{23,55},{23,56},{23,57},{23,58},{23,59},{23,60},{23,61},{23,62},{23,63},{23,64},{23,65},{23,66},{23,67},{23,68},{23,69},{23,70},{23,71},{23,72},{23,73},{23,74},{24,38},{24,39},{24,40},{24,41},{24,42},{24,43},{24,44},{24,45},{24,46},{24,47},{24,48},{24,49},{24,50},{24,51},{24,52},{24,53},{24,54},{24,55},{24,56},{24,57},{24,58},{24,59},{24,60},{24,61},{24,62},{24,63},{24,64},{24,65},{24,66},{24,67},{24,68},{24,69},{24,70},{24,71},{24,72},{24,73},{24,74},{25,38},{25,39},{25,40},{25,41},{25,42},{25,43},{25,44},{25,45},{25,46},{25,47},{25,48},{25,49},{25,50},{25,51},{25,52},{25,53},{25,54},{25,55},{25,56},{25,57},{25,58},{25,59},{25,60},{25,61},{25,62},{25,63},{25,64},{25,65},{25,66},{25,67},{25,68},{25,69},{25,70},{25,71},{25,72},{25,73},{25,74},{26,38},{26,39},{26,40},{26,41},{26,42},{26,43},{26,44},{26,45},{26,46},{26,47},{26,48},{26,49},{26,50},{26,51},{26,52},{26,53},{26,54},{26,55},{26,56},{26,57},{26,58},{26,59},{26,60},{26,61},{26,62},{26,63},{26,64},{26,65},{26,66},{26,67},{26,68},{26,69},{26,70},{26,71},{26,72},{26,73},{26,74},{27,38},{27,39},{27,40},{27,41},{27,42},{27,43},{27,44},{27,45},{27,46},{27,47},{27,48},{27,49},{27,50},{27,51},{27,52},{27,53},{27,54},{27,55},{27,56},{27,57},{27,58},{27,59},{27,60},{27,61},{27,62},{27,63},{27,64},{27,65},{27,66},{27,67},{27,68},{27,69},{27,70},{27,71},{27,72},{27,73},{27,74},{28,38},{28,39},{28,40},{28,41},{28,42},{28,43},{28,44},{28,45},{28,46},{28,47},{28,48},{28,49},{28,50},{28,51},{28,52},{28,53},{28,54},{28,55},{28,56},{28,57},{28,58},{28,59},{28,60},{28,61},{28,62},{28,63},{28,64},{28,65},{28,66},{28,67},{28,68},{28,69},{28,70},{28,71},{28,72},{28,73},{28,74},{29,38},{29,39},{29,40},{29,41},{29,42},{29,43},{29,44},{29,45},{29,46},{29,47},{29,48},{29,49},{29,50},{29,51},{29,52},{29,53},{29,54},{29,55},{29,56},{29,57},{29,58},{29,59},{29,60},{29,61},{29,62},{29,63},{29,64},{29,65},{29,66},{29,67},{29,68},{29,69},{29,70},{29,71},{29,72},{29,73},{29,74},{30,38},{30,39},{30,40},{30,41},{30,42},{30,43},{30,44},{30,45},{30,46},{30,47},{30,48},{30,49},{30,50},{30,51},{30,52},{30,53},{30,54},{30,55},{30,56},{30,57},{30,58},{30,59},{30,60},{30,61},{30,62},{30,63},{30,64},{30,65},{30,66},{30,67},{30,68},{30,69},{30,70},{30,71},{30,72},{30,73},{30,74},{31,38},{31,39},{31,40},{31,41},{31,42},{31,43},{31,44},{31,45},{31,46},{31,47},{31,48},{31,49},{31,50},{31,51},{31,52},{31,53},{31,54},{31,55},{31,56},{31,57},{31,58},{31,59},{31,60},{31,61},{31,62},{31,63},{31,64},{31,65},{31,66},{31,67},{31,68},{31,69},{31,70},{31,71},{31,72},{31,73},{31,74},{32,38},{32,39},{32,40},{32,41},{32,42},{32,43},{32,44},{32,45},{32,46},{32,47},{32,48},{32,49},{32,50},{32,51},{32,52},{32,53},{32,54},{32,55},{32,56},{32,57},{32,58},{32,59},{32,60},{32,61},{32,62},{32,63},{32,64},{32,65},{32,66},{32,67},{32,68},{32,69},{32,70},{32,71},{32,72},{32,73},{32,74},{33,38},{33,39},{33,40},{33,41},{33,42},{33,43},{33,44},{33,45},{33,46},{33,47},{33,48},{33,49},{33,50},{33,51},{33,52},{33,53},{33,54},{33,55},{33,56},{33,57},{33,58},{33,59},{33,60},{33,61},{33,62},{33,63},{33,64},{33,65},{33,66},{33,67},{33,68},{33,69},{33,70},{33,71},{33,72},{33,73},{33,74},{34,38},{34,39},{34,40},{34,41},{34,42},{34,43},{34,44},{34,45},{34,46},{34,47},{34,48},{34,49},{34,50},{34,51},{34,52},{34,53},{34,54},{34,55},{34,56},{34,57},{34,58},{34,59},{34,60},{34,61},{34,62},{34,63},{34,64},{34,65},{34,66},{34,67},{34,68},{34,69},{34,70},{34,71},{34,72},{34,73},{34,74},{35,38},{35,39},{35,40},{35,41},{35,42},{35,43},{35,44},{35,45},{35,46},{35,47},{35,48},{35,49},{35,50},{35,51},{35,52},{35,53},{35,54},{35,55},{35,56},{35,57},{35,58},{35,59},{35,60},{35,61},{35,62},{35,63},{35,64},{35,65},{35,66},{35,67},{35,68},{35,69},{35,70},{35,71},{35,72},{35,73},{35,74},{36,38},{36,39},{36,40},{36,41},{36,42},{36,43},{36,44},{36,45},{36,46},{36,47},{36,48},{36,49},{36,50},{36,51},{36,52},{36,53},{36,54},{36,55},{36,56},{36,57},{36,58},{36,59},{36,60},{36,61},{36,62},{36,63},{36,64},{36,65},{36,66},{36,67},{36,68},{36,69},{36,70},{36,71},{36,72},{36,73},{36,74},{37,38},{37,39},{37,40},{37,41},{37,42},{37,43},{37,44},{37,45},{37,46},{37,47},{37,48},{37,49},{37,50},{37,51},{37,52},{37,53},{37,54},{37,55},{37,56},{37,57},{37,58},{37,59},{37,60},{37,61},{37,62},{37,63},{37,64},{37,65},{37,66},{37,67},{37,68},{37,69},{37,70},{37,71},{37,72},{37,73},{37,74},{38,39},{75,76},{112,113},{149,150},{186,187},{223,224},{260,261},{297,298},{334,335},{371,372},{408,409},{445,446},{482,483},{519,520},{556,557},{593,594},{630,631},{667,668},{704,705},{741,742},{778,779},{815,816},{852,853},{889,890},{926,927},{963,964},{1000,1001},{1037,1038},{1074,1075},{1111,1112},{1148,1149},{1185,1186},{1222,1223},{1259,1260},{1296,1297},{1333,1334},{1370,1371}};

int add(int x, int y) {
    return (x + y) % P;
}

int mul(int x, int y) {
    return (x * y) % P;
}

PIII mul(PIII pt, int k) {
    return MP(MP(mul(pt.FF.FF, k), mul(pt.FF.SS, k)), mul(pt.SS, k));
}

PIII add(PIII p, PIII q) {
    return MP(MP(add(p.FF.FF, q.FF.FF), add(p.FF.SS, q.FF.SS)), add(p.SS, q.SS));
}

PIII canonical(PIII pt) {
    if (pt.SS != 0) {
        return mul(pt, inv[pt.SS]);
    }
    else if (pt.FF.SS != 0) {
        return mul(pt, inv[pt.FF.SS]);
    }
    else {
        return mul(pt, inv[pt.FF.FF]);
    }
}

vector<PIII> pts;
map<PIII, int> pts2idx;

int main() {
    inv[1] = 1;
    for (int i = 2; i < P; i++) { inv[i] = (P - (P / i) * inv[P % i] % P) % P; }

    FORN(i, P) {
        FORN(j, P) {
            auto pt = MP(MP(i, j), 1);

            pts2idx[pt] = pts.size();
            pts.PB(pt);
        }
    }

    FORN(i, P) {
        auto pt = MP(MP(i, 1), 0);

        pts2idx[pt] = pts.size();
        pts.PB(pt);
    }

    pts2idx[MP(MP(1, 0), 0)] = pts.size();
    pts.PB(MP(MP(1, 0), 0));

    cout << P*P + P + 1 << " " << P+1 << "\n";

    FORN(i, 1407) {
        auto x = pts[lines[i][0]-1];
        auto y = pts[lines[i][1]-1];

        set<int> line;

        FORN(j, P) {
            FORN(k, P) {
                auto pt = add(mul(x, j), mul(y, k));

                if (pt != MP(MP(0, 0), 0)) {
                    pt = canonical(pt);
                    line.insert(pts2idx[pt]+1);
                }
            }
        }

        for (auto& i : line)
        {
            cout << i << " ";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 512