for i in range(2,1+z[1]):#optimization from exercise 1-5