
Given a chronological list of events logs of the form (timestamp, book_id, is_checkout) where is_checkout is True for a checkout and False for a return, implement a validator. For each book_id, the sequence must start with a checkout, alternate strictly between checkout and return, and must never contain a return before a checkout. The function should return True if all book_id sequences are valid and False otherwise. Specify the time and space complexity.