The dead were among five people trapped inside the first train carriage which derailed while one of the other three was rescued.