#ABC120D. [ABC120D] Decayed Bridges

[ABC120D] Decayed Bridges

Score : 400400 points

Problem Statement

There are NN islands and MM bridges.

The ii-th bridge connects the AiA_i-th and BiB_i-th islands bidirectionally.

Initially, we can travel between any two islands using some of these bridges.

However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the MM-th bridge.

Let the inconvenience be the number of pairs of islands (a,b)(a, b) (a<ba < b) such that we are no longer able to travel between the aa-th and bb-th islands using some of the bridges remaining.

For each ii (1iM)(1 \leq i \leq M), find the inconvenience just after the ii-th bridge collapses.

Constraints

  • All values in input are integers.
  • 2N1052 \leq N \leq 10^5
  • 1M1051 \leq M \leq 10^5
  • 1Ai<BiN1 \leq A_i < B_i \leq N
  • All pairs (Ai,Bi)(A_i, B_i) are distinct.
  • The inconvenience is initially 00.

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

AMA_M BMB_M

Output

In the order i=1,2,...,Mi = 1, 2, ..., M, print the inconvenience just after the ii-th bridge collapses. Note that the answer may not fit into a 3232-bit integer type.

4 5
1 2
3 4
1 3
2 3
1 4
0
0
4
5
6

For example, when the first to third bridges have collapsed, the inconvenience is 44 since we can no longer travel between the pairs (1,2),(1,3),(2,4)(1, 2), (1, 3), (2, 4) and (3,4)(3, 4).

6 5
2 3
1 2
5 6
3 4
4 5
8
9
12
14
15
2 1
1 2
1