Potemkin cycle
Prince Potemkin is well-known for his fake villages, created in haste to impress visiting dignitaries. He would lead the delegation along a closed route in his territory, and at each suitable site, a troupe of actors would erect a mobile village and pretend to be its inhabitants. Once the delegation moved, the actors disassembled the village and rushed ahead of the delegation to the next suitable site.
Of course, choosing the right route requires some thought. The members of the delegation occasionally leave the planned route for short inspection trips, and if they ever came back to a site they previously visited, the ruse would fail, since they would see an empty spot where they previously saw a village. Also, to properly impress, the route should pass through at least four sites.
You are given a map of Potemkin's territory, including the list of bidirectional direct roads among the suitable sites (the crossings among the direct roads are handled by an intricate system of overpasses, making it impossible for the dignitaries to switch from one road to another at any point other than its ends). Prince Potemkin asked you to find a sequence s[1]
, ..., s[m]
of sites such that:
m ≥ 4,
all sites are different (that is,
s[i]
≠s[j]
for all i ≠ j),s[i]
is joined tos[i+1]
by a direct road for i = 1, ..., m - 1, ands[m]
is joined tos[1]
by a direct road, andthere are no other direct roads among the sites in the sequence (i.e., for all i < j such that j ≠ i + 1 and either i ≠ 1 or j ≠ m, the sites
s[i]
ands[j]
are not joined by a direct road).
Input
The first line contains two non-negative integers n and r (0 ≤ n ≤ 1000, 0 ≤ r ≤ 10^5
), denoting the number of sites and the number of direct roads among them, respectively. The i-th of the following r lines contains two distinct positive integers a[i]
and b[i]
(1 ≤ a[i]
, b[i]
≤ n), showing that the sites a[i]
and b[i]
are joined by a direct road. Each two sites are joined by at most one road.
Output
Write a sequence s[1]
, ..., s[m]
of pairwise distinct integers, describing a route as specified in the problem statement (an arbitrary one, if more valid sequences exist). If no such sequence exists, write "no" instead.