i = 1000
while len((x:=str(i))) == 4:
if x[0] == x[-1]:
print(i)
i += 1
i = 1
while i != 10:
j = 0
while j != 10:
k = 0
while k != 10:
print(''.join(str(e) for e in [i, j, k, i]), end=' ')
k += 1
j += 1
i += 1