list = []
while True:
s = input()
if s == '0':
break
else:
list.append(s)
print(' '.join(list))

list = []
while True:
s = input()
if s == '0':
break
else:
list.append(s)
print(' '.join(list))