A train travels from City A to City B, a distance of 300 miles, at an average speed of 60 miles per hour. On the return trip, due to maintenance work on the tracks, the train travels at an average speed of 40 miles per hour. How much total time does the train spend traveling between the two cities? Let's think step by step and output the final answer within \boxed{}.
user