Four products from the cyanoacetylation of pyrimidines: hydrogen-bonded dimers, pi-stacked hydrogen-bonded chains and hydrogen-bonded chains of edge-fused rings.