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-q*l2 return l1