smallq looping xgcd