Once you attempt the question then PrepInsta explanation will be displayed.

Let the distance of train be any value ( if you don't want to solve by taking x. )

Let the length of each train = L.C.M. of the time given 29 and 19 (for simplicity) = 551 meters.

Passing a pole means, crossing its own length.

So, for train 1.

Distance covered in passing a pole = length of train 1 =551 meter.

Time taken = 29 sec.

So, Speed of train 1 = 551/29 = 19 m/s

For train 2:

Speed of train 2 = \frac{551}{19} = 29 m/s

( These data can be assumed in solving relatively. If x would have been taken in place of 551, the process would have been the same. If confused, think x=551. )

Opposite direction movement, time taken to cross:

In opposite direction, the relative speed is added up.

So, relative speed = 19 + 29 = 48 m/s

Relative Distance covered for both trains to cross each other = sum of the length of both trains

= 551 + 551 = 1102 m

So, time taken for both trains to cross each other= distance/ relative speed

= \frac{1102}{48} sec

=22.9 sec.