Project Euler 457 - A polynomial modulo the square of a prime

Official link: https://projecteuler.net/problem=457