solve the Residue