A travels the first third of the distance, or 200 miles, at 40 mph, so that takes 5 hours.
B is traveling at its different speeds for equal amounts of time, so its average speed overall will just be the normal average of its speeds, and it will average (40 + 50 + 60)/3 = 50 mph for the trip, and its total time will thus be 12 hours. So it travels for 4 hours at each speed, and in particular, it travels the first 4 hours at 40 mph, and covers 160 miles, and then travels the next hour at 50 mph, and covers a further 50 miles, so after 5 hours, it has traveled 210 miles.
So after 5 hours, both trains are traveling at 50 mph, and the trains are 190 miles apart. They'll continue to travel at 50 mph until they meet, so now it's just a standard converging speed problem; the distance between the trains is falling at 50+50 = 100 mph, and they are 190 miles apart, so it will take 1.9 hours for the two trains to meet. At 50 mph, each travels 95 miles in 1.9 hours, so in total, train A has traveled 295 miles when they meet, and B has traveled 305 miles. The answer choices all measure the distance from city M, so the question is asking how far A has traveled, and 295 miles is the answer.