Added validation: p and q cannot both be zeros