Write a function to implement a simple state machine.
The function receives a transition map, an initial state, and an ordered list of events: def run_state_machine(transitions, initial_state, events):.
For each event, move to the configured next state; if no transition exists for the current state and event, remain in the current state. Return the final state.
def run_state_machine(transitions, initial_state, events):