Lets denote position M as our 0 point. Thus point N is at 380 mi
Let m = speed of train starting from point M. Let xm be distance train has traveled.
Let n = speed of train starting from point N. Let xn be distance train has traveled.
Since speed = distance/time we have
xm = 0+m*t (remember we are taking point M as 0 point)
xn = 380-n*t (point N is at 380
We are given speed of train starting at point N was 5 mph faster than one starting at point M. Thus
n = m+5
We are told after t = 2 hrs that the distance between the trains was 30 mi. Thus
|xm-xn| = |(0+m*t)-(380-n*t)| = |m*t-380+n*t| = |m*t-380+(m+5)*t| = |2m*t+5t-380|
Plug in t = 2
|2m*2+5*2-380| = |4m+10-380|=|40-370| = 30
So we have two equations
4m-370 = 30 which means m = 400/4 = 100 mph
or
-(4m-370) = 30 which means 4m-370 = -30 which means m = 340/4 = 85 mph
From this n = 105 mph or n = 90 mph
Option 1:
If m = 100 mph then xm = 100*2 = 200 miles
This means n = 105 mph and xn = 380-105*2 = 170 miles
I think we can discard this because this means the trains have passed each other. I'm thinking the problems wants before they pass each other.
Option 2:
If m = 85 mph then xm = 85*2 = 170 miles
This means n = 90 mph and xn = 380-90*2 = 200 miles
This is probably the likely case.
So your answer is the train leaving from M was at 85 mph and the train leaving from point N was at 90 mph.