The effect of both trains moving in opposite directions is the same that if one of them was stationary and the other one was moving at 65 + 72 = 137 mph.
Now, we know that distance = speed x time. Let's call the distance d and the time y
We would have:

Using the distance we're given,

Solving for t :

It would take 6 hours for them to be 822 miles apart .