def bezout(a,b): l1=[1,0,a] l2=[0,1,b] while l2[2]!=0: q=l1[2]//l2[2] l1,l2=l2,[l1[0]-q*l2[0],l1[1]-q*l2[1],l1[2]-q*l2[2]] return l1