Solution:
Two trains are moving in opposite direction with Speed 40 kmph and 60 kmph. Make train B stationary and then take the Speed of train A relative to the train B. So relative Speed of train A = 40 + 60 = 100 kmph. Before it crashes into the stationary train B it has to travel a Distance of 200 m which it will do in (0.2/100 ) hours. During this duration, the average Speed of bird has been 10 kmph i.e. before the crash total Distance covered by the bird = 0.2 * 10/100 km = 20 meters.
Hope it helps