You are given an integer
crepresentingcpower stations, each with a unique identifieridfrom 1 toc(1‑based indexing).These stations are interconnected via
nbidirectional cables, represented by a 2D arrayconnections, where each elementconnections[i] = [ui, vi]indicates a connection between stationuiand stationvi. Stations that are directly or indirectly connected form a power grid.Initially, all stations are online (operational).
You are also given a 2D array
queries, where each query is one of the following two types:
[1, x]: A maintenance check is requested for stationx. If stationxis online, it resolves the check by itself. If stationxis offline, the check is resolved by the operational station with the smallestidin the same power grid asx. If no operational station exists in that grid, return -1.[2, x]: Stationxgoes offline (i.e., it becomes non-operational).Return an array of integers representing the results of each query of type
[1, x]in the order they appear.Note: The power grid preserves its structure; an offline (non‑operational) node remains part of its grid and taking it offline does not alter connectivity.