#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
int MOD = 10;
const ld E = 1e-9;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef LONG_LONG_MAX
#define LONG_LONG_MAX LLONG_MAX
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define prev time_prev
#ifndef M_PI
#define M_PI acos(-1)
#endif
#define remove tipa_remove
#define next tipa_next
#define left tipa_left
#define right tipa_right
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline bool read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n') {
			if (ccc == '\n')
				return true;
			break;
		}
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
	return false;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (x < 0) {
		putchar('-');
		x *= -1;
	}
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
}
#ifdef LOCAL
#define DEBUG
#endif
#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

int n, k;

int has[2000];

vector<int> v[2000];

int timer = 0;

int t[2000];

int check(int a, int b) {
	timer++;
	for (int x : v[a]) {
		t[x] = timer;
	}
	int ans = 0;
	for (int y : v[b]) {
		if (t[y] == timer) {
			ans++;
		}
	}
	return ans;
}

void dfs(int a, int b) {
	if (a == n) {
		for (int i = 0; i < n; i++) {
			for (int a : v[i]) {
				cout << a << " ";
			}
			cout << endl;
		}
		exit(0);
	}
	if (b == k) {
		bool ok = true;
		for (int i = 0; i < a; i++) {
			if (check(i, a) != 1) {
				ok = false;
				break;
			}
		}
		if (ok) {
			dfs(a + 1, 0);
		} else {
			return;
		}
	}
	int last = (v[a].empty() ? 0 : v[a].back());
	for (int i = last + 1; i <= n; i++) {
		if (has[i]) {
			v[a].push_back(i);
			has[i]--;
			bool ok = true;
			for (int j = 0; j < a; j++) {
				if (check(j, a) > 1) {
					ok = false;
					break;
				}
			}
			if (ok) {
				dfs(a, b + 1);
			}
			has[i]++;
			v[a].pop_back();
		}
	}
}

void solve(int n, int k) {
	::n = n;
	::k = k;
	for (int i = 1; i <= n; i++) {
		has[i] = k;
	}
	v[0].clear();
	for (int i = 1; i <= k; i++) {
		v[0].push_back(i);
		has[i]--;
	}
	dfs(1, 0);
}

int ar[2000][2000];

int main() {
	sync;
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
#ifdef LOCAL
	input;
	output;
#else

#endif

	int k = 38;
	int n = 1 + k * (k - 1);
	cout << n << " " << k << endl;
	if(0) {
		cin >> n >> k;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < k; j++) {
				int a;
				cin >> a;
				has[a]++;
				v[i].push_back(a);
			}
		}
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				if(check(i, j) != 1){
					cout << i << " " << j << endl;
				}

			}
		}
		for(int i = 0; i < n; i++) {
			assert(has[i + 1] == k);
		}

		return 0;
	}
	int e = 2;
	for(int i = 0; i < k; i++) {
		cout << 1;
		for(int j = 1; j < k; j++) {
			ar[i][j] = e;
			cout << " " << (e++);
		}
		cout << endl;
	}
	for(int i = 2; i <= k; i++) {
		for(int j = 1; j < k; j++) {
			cout << i;
			int pos = j;
			for(int z = 1; z < k; z++) {
				cout << " " << (ar[z][pos]);
				pos += i - 2;
				if(pos >= k) {
					pos -= k - 1;
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 640