Optimal coefficients modulo prime powers in the three-dimensional case