target = [42, 15, 70, 26]
target.sort()
text = 'a)'
for i in target:
	if i % 3 == 0 and i % 7 == 0:
		text += ' '+str(i)
text += '\nb)'
for i in target:
	if i % 3 == 0 or i % 7 == 0:
		text += ' '+str(i)
print(text)