Extended Euclidean Algorithmw