Trains problem