Simulate a system of trains using stack data structures.