#include <bits/stdc++.h>
using namespace std;

const string week[7] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int main() {
	srand(4202265);
	int n =rand() % 20 + 1, m =rand() % 20 + 1;

	cout << n << " " << m << endl;
	for (int i = 1; i <= n; i++) {
		vector<int> vec;
		for (int j = 1; j <= m; j++) vec.push_back(j);

		for (int j = 1; j <= m; j++) {
			if (j != 1) printf(" ");
int have = rand() % (int)vec.size();
			printf("%d", vec[have]);
	vec.erase(vec.begin() + have);
			
		}
		puts("");
	}
	return 0;
}
