Sped the algorithm up STUPENDOUSLY by using the three argument version of python's pow() function to do efficient, quick modular exponentiation. It now runs around 10,000 times faster.