def mox(x,p): z=x/p z1=int(z) return x-z1*p p=7 for x1 in range(p): for y1 in range(p): z=x1-y1 if z<0:z=y1-x1 print(mox(z,p)