Into whatever made them stick. In the real world, this is usually deformation of something (grinding metal. Or maybe the mating portions are clay that sticks together and deforms. Or barrels filled with water like they have to minimize damage at traffic off-ramps) or dissipation in specially designed systems (Wonderful shock absorbers with magical dashpots) If you just have springs, though, the two trains won’t stick – they’ll bounce off each other and you’ll have a perfectly elastic collision.
10m kg*m[sup]2[/sup]/sec[sup]2[/sup]