When X acts as zero, resolve the firstmodule with the Koszul resolution on (p,X). Writing N=Z/q, the resulting groups are ker(p:N→N) in degree zero, (N/pN)⊕kerp in degree one, and N/pN in degree two, with zero higher groups. This works for composite as well as prime moduli.