Let the speed of the second train be x km/hr.
Then the speed of the first train is (x + 5) km/hr.
Let O be the position of the railway station from which the two trains leave.
Distance travelled by the first train in 2 hours = OA = Speed × Time = 2(x + 5)km
Distance travelled by the second train in 2 hours in OB = speed × Time = 2x km
Hence, the speed of the second train is 15 km/hr and the speed of the first train is 20 km/hr.