Simple polymers can be potentially formed by the cooligomerization of pyrimidine nucleobases, uracil and cytosine, with the small molecule formaldehyde. Using density functional calculations, we have constructed a free energy map outlining the thermodynamics and kinetics for (1) the addition of formaldehyde to uracil and cytosine to form hydroxymethylated uracil (HMU) and hydroxymethylated cytosine (HMC), (2) the deamination of cytosine and HMC to uracil and HMU, respectively, and (3) the initial oligomerization of 5-HMU. For the initial formation of monomeric HMU, addition of formaldehyde to the C5 and C6 positions is thermodynamically favored over N1 and N3, but faces higher kinetic barriers, and explains why 5-HMU is the main product observed experimentally. Oligomerization of 5-HMU is thermodynamically favorable although decreasingly so at the tetramer stage. In addition, decreasing concentrations of initial monomer shifts the equilibrium disfavoring oligomer formation.