def reconstruct(A, B, z):
 f = factorint(igcd(A, B))
 for (p, e) in f.items():
  if (e != 1):
   raise ValueError('a and b should be square-free')
  z *= p
 return z

def reconstruct ( A , B , z ) : f = factorint ( igcd ( A , B ) ) for ( p , e ) in f . items ( ) : if ( e != 1 ) : raise ValueError ( 'a and b should be square-free' ) z *= p return z
reconstruct the z value of an equivalent solution of ax^2 + by^2 + cz^2 from the z value of a solution of the square-free normal form of the equation .