Given
- Number of students, games, and connection events
- For each student, the game they like
- A sequence of connections between pairs of students over time
For each game, determine the earliest time when all students who like that game become connected (either directly or indirectly). Output -1 if they never get connected.