Shunting

Model railway enthusiasts have created a whole class of mathematical problems
to solve that involve manouvering locomotives and carriages around specially
constructed track layouts. One of the earliest and simplest railway shunting
problems is presented here.

The puzzle

In the FA Cup Grantham have to travel to Spalding United and Boston face a
trip to Ilkeston. Special trains are put on to get the fans of each team to
the match. Each train consists of a locomotive and two carriages. On the day
of the match both trains end up heading towards each other on a stretch of single
line track. There is however a siding that can take one locomotive and one carriage.
How is it possible for the two trains to pass each other by using this siding?