Circular route
In one country N cities connected by a network of roads. Network such that from every city you can reach any other, moving along the roads. The President has decided to follow in the footsteps of Franklin Delano Roosevelt and the unemployed to take a road construction, but building materials for new roads in sufficient numbers were not available, and decided to dismantle part of the old roads to improve the remaining roads.
The President wants to remove the few roads that form a ring route (cycle) so that the remaining roads could still get from each city in each. Locate a circular route, or say that it does not exist.
Input
The first line contains two integers N and M, the number of cities and roads, respectively (1 <= N <= 100 000, 2N <= M <= 3N). In the following M lines are given road. Each road sets the number of cities, which it connects. Cities are indexed by numbers from 1 to N. Between the two cities may be several roads, the road can also connect the city with itself.
Output
Derive the number of –1, if desired route does not exist. If it exists, output a number of cities, forming the route.