//* Problem  : F - Lotto
//* Contest  : UzhNU Local
//* Origin   : Ulm-1996
//* Type     : Solution
//* Date     : 2008.02.04
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0
//* Algoritm : Straightforward

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int n, a[100];

int main()
{
	int nt = 0;
	while (1)
	{
		scanf("%d", &n); if (!n) break;
		if (nt) putchar('\n'); nt++;
		int i;
		for (i = 0; i < n; i++)
			scanf("%d", &a[i]);
		for (int i1 = 0; i1 < n - 5; i1++)
			for (int i2 = i1+1; i2 < n - 4; i2++)
				for (int i3 = i2+1; i3 < n - 3; i3++)
					for (int i4 = i3+1; i4 < n - 2; i4++)
						for (int i5 = i4+1; i5 < n-1; i5++)
							for (int i6 = i5+1; i6 < n; i6++)
							printf("%d %d %d %d %d %d\n", a[i1], a[i2], a[i3], a[i4], a[i5], a[i6]);
	}
	return 0;
}