100 atcoder#ABC120D. [ABC120D] Decayed Bridges
[ABC120D] Decayed Bridges
Score : points
Problem Statement
There are islands and bridges.
The -th bridge connects the -th and -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 -th bridge.
Let the inconvenience be the number of pairs of islands () such that we are no longer able to travel between the -th and -th islands using some of the bridges remaining.
For each , find the inconvenience just after the -th bridge collapses.
Constraints
- All values in input are integers.
- All pairs are distinct.
- The inconvenience is initially .
Input
Input is given from Standard Input in the following format:
Output
In the order , print the inconvenience just after the -th bridge collapses. Note that the answer may not fit into a -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 since we can no longer travel between the pairs and .
6 5
2 3
1 2
5 6
3 4
4 5
8
9
12
14
15
2 1
1 2
1