So, Brianna, let's look at what we have. Distance = rate x time, right?
If we say p = the passenger train's rate, then it's gone 3p miles when it overtakes the freight train.
The freight train has been travelling for 5 hours at 18 mph slower, so it's gone 5(p - 18) = 5p - 90 miles.
If they are meeting, then they have both travelled the same distance!
3p = 5p - 90
2p = 90
p = 45
This means that the passenger train was travelling at 45 mph and the freight train at 45 - 18 = 27 mph.
Let's check. In 5 hours, the freight train travelled 5(27) = 135 miles. The passenger train travelled 3(45) = 135 miles. Check!