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

using namespace std;

const int KMAX = 12;

vector<int> station[3*KMAX];
int k, n, m;

int main()
{
	scanf("%d %d", &k, &n);

	int i, j, x;
	int rn;

	for (i = 1; i <= n; i++) {
	   	scanf("%d", &m);
		for (j = 0; j < m; j++) {
			scanf("%d", &x);
			station[i].push_back(x);
		}

		if (station[i][0] != 0) {
			i--;
			break;
		}
	}

	printf("%d\n%d\n", k, n);

	rn = i;
	for (i = rn; i >= 1; i--) {
		printf("%d ", station[i].size());
		for (j = 0; j < station[i].size(); j++)		
			printf("%d ", station[i][j]);
		printf("\n");
	}

	if (rn < n) {
		printf("%d ", station[rn + 1].size());
		for (j = 0; j < station[rn + 1].size(); j++)
			printf("%d ", station[i][j]);
		printf("\n");

		for (i = rn + 2; i <= n; i++) {
			scanf("%d", &m);
			printf("%d ", m);
			for (j = 0; j < m; j++) {
				scanf("%d", &x);
				printf("%d ", x);
			}
			printf("\n");
		}
	}
	return 0;
}
