Answer:
We assume the second train was standing still and that momentum is conserved.
Then the product of mass and velocity before the collision is
(5000 kg)·(100 m/s) = 500,000 kg·m/s.
After the collision, where M is the mass of the second train, the momentum is
((5000+M) kg)·(50 m/s) = 500,000 kg·m/s
Dividing by 50 m/s and subtracting 5000 kg, we have
(5000 +M) kg = 10,000 kg
M kg = 5000 kg
The mass of the second train is 5000 kg