count = 0 for i in range(1800, 2023): if (i % 4 == 0 and i % 100 != 0) or i % 400 == 0: count += 1 print(i, end=("\n" if count % 8 == 0 else " "))