Hyperways

After each edge is added to a multigraph, report how many edges became safe, where an edge is safe when it lies on a cycle.

Hard8Union-findGraphDFSImplementationNo attempts yetTime limit3sMemory limit1024 MB

Problem

The intergalactic company Oods&co is building a network of hyperways that connects the planets of our galaxy. The construction plan is already prepared, and it fixes the order in which the hyperways are built. Each hyperway is a bidirectional corridor between two planets, and both ends may be the same planet.

A hyperway HH is unsafe if there are two planets AA and BB such that every trip from AA to BB has to use HH. If no such pair of planets exists, HH is safe, which is the same as saying that HH is not the only hyperway connecting some pair of planets, directly or indirectly. Safe hyperways are exactly the ones that lie on some cycle.

You are given the order in which the hyperways are built. Right after a hyperway is built, some hyperways may have just become safe, and the hyperway that was just built may be one of them. Count them after every construction. A hyperway that is already safe stays safe for the rest of the construction.

Input

The first line contains two integers nn and mm. Here nn is the number of planets in the plan and mm is the number of hyperways. The planets are numbered 11 through nn.

Each of the next mm lines contains two space separated integers, the ids of the planets that the next hyperway joins. A hyperway may connect a planet with itself, and several hyperways may connect the same two planets.

In all inputs, 1n1061 \le n \le 10^6 and 1m2×1061 \le m \le 2 \times 10^6.

Output

For each hyperway in the input, print one line with one integer, the number of hyperways that became safe right after that hyperway was built.