A city is expanding its public rail network. Several expansion routes are being considered, but the budget is limited, so only some of them can be built. Your task is to choose the affordable subset of proposed routes that reduces the total passenger travel time as much as possible.
You are given the current rail system and up to 10 proposed expansion routes. Choose a subset of the proposed routes whose total price does not exceed the budget so that the total travel time of all passengers is reduced by the largest possible amount.
Travel-time model: riding from one station to an adjacent station on any route takes exactly one minute, and transferring between routes at a shared station is instantaneous. Every route can be traveled in both directions. Even before any expansion the current system is already connected, so every station is reachable from every other station. The travel time between two stations is therefore the minimum number of station-to-station hops between them.
The first line contains the number of data sets $K$. Each data set then follows in this form:
Stations are numbered from $1$ to $n$.
For each data set, output a line Data Set x:, where $x$ is the data set number (starting at $1$). On the next line, output a single integer: the maximum total reduction in the sum of all passengers' travel times that can be achieved by building a subset of the proposed routes whose combined price does not exceed the budget.