
Given a list of lifecycle event strings events, determine whether the sequence is valid. Each event is one of "PLAN", "EXECUTE", "DEFECT", "RETEST", or "CLOSE". A valid sequence must follow these rules: PLAN must occur before any other event, EXECUTE can occur only after PLAN, every DEFECT must be matched by a later RETEST, and CLOSE can appear only once at the end after all defects have been retested. Return True if the sequence is valid, otherwise return False.
1 <= len(events) <= 10^5events[i] is one of "PLAN", "EXECUTE", "DEFECT", "RETEST", "CLOSE"CLOSE, if present, must be the final event in a valid sequence