# In the support service, tickets can generate sub-tickets.
# The system logs every action: opening or closing a ticket. Events arrive in chronological order.
# It is important to verify that the sequence of events is correct:
# You cannot close a ticket that was not opened.
# You cannot open an already open ticket (its ID is already among open tickets).
# Closure must occur in the reverse order of opening (nesting): the last opened ticket should be closed first.
# Implement a function that takes a list of events (each element is a dictionary with keys 'type' ('open' or 'close') and 'ticket_id').
# Examples:
# [
# {'type': 'open', 'ticket_id': 'A'},
# {'type': 'open', 'ticket_id': 'B'},
# {'type': 'close', 'ticket_id': 'B'},
# {'type': 'close', 'ticket_id': 'A'}
# ]
# result True
#
# [
# {'type': 'open', 'ticket_id': 'A'},
# {'type': 'close', 'ticket_id': 'B'}
# ]
# Result False.