Huge cacti in the Hortus botanicus in Leiden. Before entering the contest site, you decide to wander around in the Hortus botanicus in Leiden. You come across some huge cacti. After walking some more, you decide to take a look at a map of the Hortus botanicus, and figure that all the walking routes can be modelled as a graph. Each route connects two different intersections and can be represented by an edge with some length. After investigating the map, you come to a delightful conclusion: the graph of the garden is a cactus graph! From a graph theory course you once took, you remembered the definition:
Def. Cactus graph: A connected, simple, undirected graph is a cactus graph if every edge lies on at most one cycle.
Having fallen for the Hortus botanicus, you want each of your $$$k$$$ friends to enjoy it too, so you will plan a personal Kaktus Kourse for every one of them.
You start a Kourse at one intersection of the garden and walk along the routes to a different intersection, never visiting the same intersection twice (repetition would bore your friends). Its length is the total length of the routes traversed. A Kourse is described by the sequence of intersections visited, in order: two Kourses are different if their sequences differ. In particular, walking a Kourse backwards gives a different Kourse.
Every friend must receive a different Kourse, and you want even the shortest one handed out to be as long as possible. What is the largest possible length of the shortest Kourse you give out? If the garden has fewer than $$$k$$$ distinct Kourses, output "impossible".
An illustration of sample $$$1$$$. The cactus graph mostly matches the actual map of the Hortus botanicus Leiden, but with some minor routes left out. All the cycles of the cactus graph are drawn in different colours. Two cycles can share an intersection, but never a route. The input consists of:
If the garden has fewer than $$$k$$$ distinct Kourses, output "impossible". Otherwise, output the length of the shortest Kourse handed out to one of your friends.
12 14 5 2 3 12 2 5 22 3 4 13 4 5 10 5 6 10 5 8 21 6 9 23 8 9 9 10 11 21 10 12 17 11 12 47 1 2 10 6 7 10 9 10 45
190
3 3 3 1 2 1 2 3 2 1 3 4
5
4 3 1 3 4 1000000000 1 2 1000000000 2 3 1000000000
3000000000
4 3 12 1 2 1000000000 3 4 1000000000 2 3 1000000000
1000000000
4 3 13 1 2 1000000000 2 3 1000000000 3 4 1000000000
impossible
| Name |
|---|


