from itertools import*;d='1'
while'0'!=d:d=input();[print(' '.join(x))for x in combinations(d.split()[1:],6)];print()
from itertools import*;d='1'
while'0'!=d:d=input();[print(' '.join(x))for x in combinations(d.split()[1:],6)];print()