# olympiad.py 
# Fig. 10.5 

N = 8000; M = 132
x = [1]*N
a = [0]*N
a[1] = 1
i = 1; j = 1
while (j < M):
  for k in range(j):
    ''' sieve out all elements Which form an 
      arithmetic progression With any two of 
      a[0] to a[j-1]
    '''
    x[2*i - a[k]] = 0
  # find the first element not sieved out
  i += 1
  while x[i] != 1:
    i += 1
  # in a[] store i where x[i]=1
  j += 1
  a[j] = i
for i in range(M):
  print(f'{a[i]:6}',end='')
  if (i+1) % 12 == 0:
    print()
