You'd better draw a picture of this problem.
The distance from A to the midpoint is 40X3-25=95km, so the distance from B to the midpoint is also 95km. Because the express train is 7 kilometers away from the local train after 3 hours, and the local train has gone 95-25-7 = 63 kilometers. So the local train is 63 divided by 3=2 1km per hour.