The world is an undirected connected graph of

vertices and

edges, and each edge is in at most one simple ring. So as well known, the graph can be described as a cactus.
There are

graduating stutents in the world this time. For the

-th student, his/her college, dream, and life are at vertex

,

,

respectively. And for each student, he/she should go from his college vertex to life vertex as he/she is graduated. However, no one wants to abandon the dreams easily, so for the

-th student, he/she wants to find a vertex

that

is possibly in the shortest path between

and

(there is at least one path that contains

, that is from

to

and that has minimum possible number of edges), and possibly in the shortest path between

and

. If multiple valid vertices, choose the one with the maximum distance(the number of edges in the shortest path) to

, if still multiple valid vertices, choose the one with the minimum index.