# -*- coding: cp1251 -*- # Extended Euclidean algorithm def xgcd(x,y): a0=1; b0=0 a1=0; b1=1 if x<0: x *= -1 a0 = -1 if y<0: y *= -1 b1 = -1 if x