Let say the two train cars are of masses
and 
now if the speed of two cars are
and 
then we can say that the momentum of two cars before they collide is given by

here two cars are moving in opposite direction so we can say that the net momentum is subtraction of two cars momentum.
Now since in these two car motion there is no external force on them while they collide
So the momentum of two cars are always conserved.
hence we can say that the final momentum of two cars will be same after collision as it is before collision
