Solve LeetCode 1101, The Earliest Moment When Everyone Become Friends.
Implement earliest_acq(logs, n), where each log is [timestamp, person_a, person_b]. Return the earliest timestamp at which all n people are connected through friendship relationships, or -1 if this never occurs.
Input logs may be unordered. Each person is represented by an integer from 0 to n - 1.
def earliest_acq(logs, n):