# MH RIYAD
# Daffodil Intl. Univarsity
import functools
printf = functools.partial(print, end="")
lis = list()
li = list()
vec = list()
a = 0
flag = False
def call( n ):
if len(vec)==6:
for i in range (0,6):
if i == 0:
printf(vec[i])
else:
printf("",vec[i])
print("")
return
if n>=a:
return
vec.append(lis[n])
call(n+1)
vec.pop()
call(n+1)
if __name__ == "__main__":
while True:
li = list(map(int ,input().split()))
a = li[0]
if a==0:
break
if flag == True:
print("\n")
flag = True
for i in range(1,len(li)):
lis.append(li[i])
#print(lis," ",a)
call(0)
del lis[:]
del vec[:]
del li[:]
# Daffodil Intl. Univarsity
import functools
printf = functools.partial(print, end="")
lis = list()
li = list()
vec = list()
a = 0
flag = False
def call( n ):
if len(vec)==6:
for i in range (0,6):
if i == 0:
printf(vec[i])
else:
printf("",vec[i])
print("")
return
if n>=a:
return
vec.append(lis[n])
call(n+1)
vec.pop()
call(n+1)
if __name__ == "__main__":
while True:
li = list(map(int ,input().split()))
a = li[0]
if a==0:
break
if flag == True:
print("\n")
flag = True
for i in range(1,len(li)):
lis.append(li[i])
#print(lis," ",a)
call(0)
del lis[:]
del vec[:]
del li[:]