How to find elapsed time for two trains to cross each other when they travel in the same direction? The problem is as follows:

Two trains which have different lengths each are going to meet by
traveling on different tracks with speeds $v_{1}$ and $v_{2}$
respectively. They take $20\,s$ to cross each other. If they go to
meet with speeds $v_{1}$ and $\frac{8}{5}v_{2}$ respectively they
require $15\,s$. How long will they need to cross each other if they
travel on the same direction with speeds $v_{1}$ and $v_{2}$?

The answer in my book is : $180\,s$
I assumed that the catch here is to make a system of equations. What I could spot here was:
$d_1: \textrm{length of the first train}$
$d_2: \textrm{length of the second train}$
But I came stuck at how to relate when they are traveling in opposite directions.
Since both are moving against each other I'm assuming that their speeds subtract from each other, but how does this account for the length of each train?.
I thought this:
$\textrm{v_total} \times t_{cross}=d_{1}+d_2$
$\textrm{v_total= sum of the vectors from the speeds}$
$(v_1-v_2)20= d_1+d_2$
But this doesn't specifically indicates which is faster.
The other equation would be
$\left(v_1-\frac{8}{5}v_2\right)15=d_1+d_2$
Dividing both equations I'm getting:
$\frac{v_1-v_2}{5v_1-8v_2}=\frac{3}{20}$
Rearranging this results in:
$20v_{1}-20v_{2}=15v_1-24v_2$
Which is reduced to:
$5v_{1}+4v_2=0$
Which gets a negative quantity:
$v_{1}=-\frac{4}{5}v_2$
But from this I became confused exactly on what to do?. Can someone help me here?. Am I understanding this the correct way?. Is my assumption regarding the subtraction in speeds correct?. Because that's the part where I'm struggling the most. All and all, what would be the most appropiate way to solve this?. If a sketch could accompany the solution it would help a lot, since I'm getting confused. Any help please?.
 A: If they are traveling in opposite directions, the speeds add to get the crossing speed.  Transform to the frame of train $2$.  In that frame train $1$ is traveling at $v_1+v_2$.  The front of train $1$ has to travel the total length of both trains before the crossing is done, so the time it takes is $\frac {d_1+d_2}{v_1+v_2}$.  With this correction your approach is correct.
A: Notice in every scenario the distance traveled is the same.  They must start by touching noses.  Then the longer train's nose will touch the shorter train's butt.   Then the long train goes its distance so the longer train's butt touches the shorter trains's butt.  Together combined they travel $d_1 + d_2$.  Always.  SO let's just call that $D$
So the time it takes is $t =\frac {D}{v_1 + v_2}$.
So we have $t_1 = \frac {D}{v_1 + v_2} = 20s$  or $v_1 + v_2 = \frac D{20}$.
And $t_2 = \frac {D}{v_1 + \frac 85 v_2} = 15s$ or $v_1 + \frac 85 v_2 = \frac D{15}$.
Solving for $v_1$ and $v_2$
$20v_1 + 20v_2 = D$ and $15v_1 + 24v_2 = D$ so
$60v_1 + 60v_2 = 3D$ and $60V_1 + 96v_2 = 4D$ so
$36v_2 = D$ and $v_2 = \frac 1{36}D$ and sso
$20v_1 + \frac 59 D= D$ and $15v_1 + \frac 23D=D$ so
$20v_1 = \frac 49D$ and $15v_1 = \frac 13D$ and $v_1=\frac 4{9*20}D = \frac 1{3*15}D=\frac 1{45}D$
If they are going in the same direction then the faster one will be overtaking the other at a relative rate of the difference of there speeds.
So $t_3 = \frac {D}{v_2 - v_1} =\frac {D}{\frac 1{36}D-\frac 1{45}D}=\frac {45*36}{45-36}=$
$\frac {9*5*36}{9} = 210$ seconds.
