Python Extended Euclidean Algorithm Modular