A = []
for i in range(100, 1000):
if i % 7 == 0 and int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) == 7:
A.append(i)
print(*A)
A = []
for i in range(100, 1000):
if i % 7 == 0 and int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) == 7:
A.append(i)
print(*A)