#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

const int KMAX = 12;

vector<int> stations[3*KMAX];
vector<int> num;
int k, n;

bool cmp(int q, int w)
{
	return num[q] < num[w];
}

int main()
{
	srand(8624);
        scanf("%d %d", &k, &n);
	
	int i, j, x, m;
	for (i = 1; i <= n; i++) {
		scanf("%d", &m);
		for (j = 0; j < m; j++) {
			scanf("%d", &x);
			stations[i].push_back(x);
		}
	}
	
	for (i = 0; i <= k - 1; i++) num.push_back(i);

	if (num.size() > 1)
		random_shuffle(num.begin() + 1, num.end());
	
	printf("%d\n%d\n", k, n);
	for (i = 1; i <= n; i++) {
		printf("%d ", stations[i].size());
		stable_sort(stations[i].begin(), stations[i].end(), cmp);

		for (j = 0; j < stations[i].size(); j++) {
			printf("%d ", num[stations[i][j]]);
		}
		printf("\n");
	}

	return 0;
}
