#P9793. Cactus Vertex Guessing

    ID: 22939 Type: Default 1000ms 256MiB

Cactus Vertex Guessing

Cactus Vertex Guessing

You are given a connected cactus graph. A cactus is a connected undirected graph in which every edge belongs to at most one simple cycle; in other words, it is a tree that may have some cycles. In a game played on this cactus, Chloe secretly steals a vertex v. You make a guess by selecting some vertex u and you have at most 10 guesses to find the stolen vertex.

If your guess is v, you win. Otherwise, Chloe will give you a hint: she will tell you a vertex w such that the number of edges in a shortest path from w to v is strictly less than the number of edges in a shortest path from u to v. In this problem, you are to simulate Chloe's response in one round of the game.

Specifically, you are given a cactus graph and two integers: u which is your guess, and v the stolen vertex. If u equals v, output Found. Otherwise, find a neighbor w of u that lies on some shortest path from u to v (i.e. the distance from w to v is exactly one less than the distance from u to v). If there are multiple valid choices for w, output the one with the smallest vertex number.

Note: The input graph is guaranteed to be a cactus and is provided in the following format.

inputFormat

The input consists of multiple lines. The first line contains two integers n and m where n (2 ≤ n ≤ 105) is the number of vertices and m is the number of edges.

The following m lines each contain two integers a and b (1 ≤ a, b ≤ n) that represent an undirected edge connecting vertices a and b.

The last line contains two integers u and v (1 ≤ u, v ≤ n) representing your guessed vertex and the stolen vertex, respectively.

outputFormat

If u equals v, output the string Found (without quotes). Otherwise, output a single integer, the vertex w which is a neighbor of u and lies on a shortest path from u to v. If more than one such neighbor exists, output the smallest one.

sample

5 4
1 2
2 3
3 4
4 5
3 5
4