| 2023 USP Try-outs |
|---|
| Finished |
In 2024, the city of Guadalajara will host the 1st Latin American Final of the ICPC. For this reason, the city government is interested in promoting tourism. They have collected information about the $$$N$$$ most important tourist attractions in the city. The mayor wants to organize these attractions into tourist circuits. A tourist circuit is a sequence of distinct tourist sites, say $$$\langle p_1, p_2, \ldots, p_\ell \rangle$$$ such that $$$\ell \geq 3$$$. Tourists participating in the circuit, starting at $$$p_1$$$, visit the attractions of the circuit following the sequence until they reach the site $$$p_\ell$$$. After visiting $$$p_\ell$$$, tourists return to $$$p_1$$$ to finish the circuit. Therefore, to form the circuit, there must be a street that connects tourist sites that are consecutive in the sequence (including $$$p_1$$$ and $$$p_\ell$$$).
The city government calculates that maintaining a circuit will have a high cost. Therefore, they want to divide the $$$N$$$ tourist sites into as few circuits as possible. In other words, they want to find a set of circuits such that each tourist site belongs to a unique circuit, and the set is as small as possible. To solve this difficult task, the city government hired Marcel "the optimizer" Saito.
Marcel received information about the city's street network. After an analysis, he realized that the network satisfies the following property. For any four tourist sites $$$A$$$, $$$B$$$, $$$C$$$ and $$$D$$$, $$$$$$ d(A, B) + d(C, D) \leq \max\{ d(A, C) + d(B, D), d(A, D) + d(B, C) \}, $$$$$$ where $$$d(U, V)$$$ is the smallest number of streets we need to travel to get from $$$U$$$ to $$$V$$$.
Marcel is sure that this property is important to solve the problem at hand. Unfortunately, he needs to take care of his newest apprentice Daniel "the dynamic" Ito. Therefore, he has entrusted this task to you, the newest trainee.
The first line contains two integers $$$N$$$ ($$$1 \leq N \leq 10^5$$$) and $$$M$$$ ($$$1 \leq M \leq 10^6$$$), the number of tourist sites and the number of streets connecting these sites, respectively. Each tourist site is identified by a number from $$$1$$$ to $$$N$$$. Each of the next $$$M$$$ lines contains two integers representing the tourist sites connected by that street. Note that $$$(a)$$$ streets can be traveled in both directions, $$$(b)$$$ no two streets connect the same pair of tourist sites, $$$(c)$$$ a street does not connect a tourist site with itself, and $$$(d)$$$ by traveling the streets of the network we can go from one tourist site to any other.
The first line contains an integer $$$K$$$, the smallest number of tourist circuits that satisfy the requirements of the city government. If such a requirement is infeasible, print $$$-1$$$. Otherwise, each of the next $$$K$$$ lines describes a tourist circuit. To represent a circuit, first print an integer $$$\ell$$$, the number of tourist sites that make up the circuit. Then, print a sequence of integers $$$\ell$$$ that represents how we should travel that circuit. If there is more than one solution, any one will be accepted.
4 6 1 2 1 3 1 4 2 3 2 4 3 4
1 4 1 4 3 2
7 6 1 2 1 3 3 4 3 5 2 6 5 7
-1
| Name |
|---|


