output_description: In the order i = 1, 2, ..., M, print the inconvenience just after the i-th
  bridge collapses. Note that the answer may not fit into a 32-bit integer type.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      A_1 B_1
      A_2 B_2
      \vdots
      A_M B_M
attempt: n, m = map(int, input().split())
  ab = [list(map(int, input().split())) for i in range(m)]
  tree = [[] for i in range(n + 1)]
  parent = [0] * (n + 1)
  count = [0] * m
  for i in range(1, m + 1):
      a, b = ab[-i]
      A = parent[a]
      B = parent[b]
      if A == 0 and B == 0:
          parent[a] = a
          parent[b] = a
          tree[a].append(b)
          count[-i] = 1
      elif A == 0:
          count[-i] = len(tree[B]) + 1
          parent[a] = B
          tree[B].append(a)
      elif B == 0:
          count[-i] = len(tree[A]) + 1
          parent[b] = A
          tree[A].append(b)
      elif parent[a] == parent[b]:
          count[-i] = 0
      else:
          A = parent[a]
          B = parent[b]
          u = len(tree[A])
          v = len(tree[B])
          count[-i] = (u + 1) * (v + 1)
          if u < v:
              A, B = B, A
              a, b = b, a
          for u in tree[B]:
              parent[u] = A
          parent[B] = A
          tree[A].append(B)
          tree[A] += tree[B]
          tree[B] = []
  sum = 0
  for i in range(0, m):
      sum += count[i]
      print(sum)
  
problem_description: Statement
  
  There are N islands and M bridges.
  
  The i-th bridge connects the A_i-th and B_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 M-th bridge.
  
  Let the **inconvenience** be the number of pairs of islands (a, b) (a < b)
  such that we are no longer able to travel between the a-th and b-th islands
  using some of the bridges remaining.
  
  For each i (1 \leq i \leq M), find the inconvenience just after the i-th
  bridge collapses.
samples: [{"input": "4 5\n    1 2\n    3 4\n    1 3\n    2 3\n    1 4", "output": "0\n    0\n    4\n    5\n    6\n    \n\nFor example, when the first to third bridges have collapsed, the inconvenience\nis 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4)\nand (3, 4).\n\n* * *"}, {"input": "6 5\n    2 3\n    1 2\n    5 6\n    3 4\n    4 5", "output": "8\n    9\n    12\n    14\n    15\n    \n\n* * *"}, {"input": "2 1\n    1 2", "output": "1"}]