Implement a software simulation for a Traffic Controller or similar state-machine-driven system.
Model a four-state controller cycling through NS_GREEN, NS_YELLOW, EW_GREEN, and EW_YELLOW. Each tick advances simulated time by one unit; green and yellow states transition after their configured durations. An emergency event enters EMERGENCY, where ticks have no effect. A resume event returns the controller to NS_GREEN.
Use simulate_traffic_controller(events, green_duration, yellow_duration). Return the state after every event, excluding the initial state.
def simulate_traffic_controller(events, green_duration, yellow_duration):