Thermal decomposition of mercury thiocyanate
The reaction is the decomposition of mercury(II) thiocyanate:


  $\ce{2Hg(SCN)2 → 2HgS + CS2 + C3N4}$


Where $\ce {C3N4} $ is the compound that makes up the "snakes," and grow due to the evolution of gases produced by the decomposition of the other products:


  $\ce{CS2 + 3O2 → CO2 + 2SO2} $
  
  $\ce {2C3N4 → 3(CN)2 + N2} $
  
  $\ce {HgS + O2 → Hg + SO2}$


This is also known as the "Pharaoh's Serpent" in pyrotechnics. The resulting solid can range from dark graphite grey to light tan in color with the inside generally much darker than the outside.
Click here and here for reference.