Speed of the trains are 40km/hr and 45 km/hr
One trian is travelling with 5km/hr more than other trains and to covered 40 km more.
Hence the time taken to travel this distance = 40/5 = 8 hours
Distance between two stations = Relative speed x time
= (40 + 45 ) 8
= 85x8
= 680 km