Problem D
Catbus Planning
You are on the planning committee for upcoming Catbus routing. There are $k$ Catbuses, and your task is to choose routes for each of them. There are $n$ cities and $m$ bidirectional roads between them. A Catbus route is a path consisting of at least one road. Furthermore, Catbuses only use a road at most once because they enjoy seeking fresh paths!
It’s essential to ensure that every road is included in at least one Catbus’s route to avoid missing people. Furthermore, Catbuses can be aggressive when they encounter each other, so it’s important to ensure that no Catbus routes share the same road. However, Catbus routes can share the same cities.
Determine if it is possible to create $k$ routes. If so, print the string "Possible" followed by the $k$ routes. Otherwise print the string "Impossible".
Input
The first line of input contains three space-separated integers $n$, $m$, and $k \: (1 \leq n,m,k \leq 100\, 000)$, representing the number of cities, the number of roads, and the number of Catbuses, respectively. Each of the next $m$ lines will contain two space-separated integers $a_i$, $b_i \: (1\leq a_i,b_i\leq n, a_i\neq b_i)$ representing the $i$-th road is between city $a_i$ and $b_i$.
Output
If it is impossible to find $k$ Catbus routes, output the string "Impossible". Otherwise, output $k+1$ lines. Line $1$ of the output should be the string "Possible", and for $i=2,\ldots ,k+1$, line $i$ should consist of the list of cities that Catbus $i-1$ visits in its route in order.
Sample Input 1 | Sample Output 1 |
---|---|
4 3 4 1 2 1 3 2 4 |
Impossible |
Sample Input 2 | Sample Output 2 |
---|---|
4 3 2 1 2 1 3 4 2 |
Possible 1 2 4 1 3 |