def egcd(a, b):
x,y, u,v = 0,1, 1,0
while a != 0:
q, r = b//a, b%a
m, n = x-u*q, y-v*q
b,a, x,y, u,v = a,r, u,v, m,n
gcd = b
return gcd, x, y
print( egcd(12,25))
ZGVmIGVnY2QoYSwgYik6CiAgICB4LHksIHUsdiA9IDAsMSwgMSwwCiAgICB3aGlsZSBhICE9IDA6CiAgICAgICAgcSwgciA9IGIvL2EsIGIlYQogICAgICAgIG0sIG4gPSB4LXUqcSwgeS12KnEKICAgICAgICBiLGEsIHgseSwgdSx2ID0gYSxyLCB1LHYsIG0sbgogICAgZ2NkID0gYgogICAgcmV0dXJuIGdjZCwgeCwgeQoKcHJpbnQoIGVnY2QoMTIsMjUpKQ==