from sys import setrecursionlimit

def find(parent, i):
  t = parent[i]
  if t < 0:
    return i
  t = find(parent, t)
  parent[i] = t
  return t

def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[j] += parent[i]
  parent[i] = j

setrecursionlimit(10**6)

N, M = map(int, input().split())
AB = [[int(c) - 1 for c in input().split()] for _ in range(M)]

parent = [-1]*N
inconvenience = N*(N-1) // 2
result = []
for a, b in AB[::-1]:
  result.append(inconvenience)
  pa, pb = find(parent, a), find(parent, b)
  if pa != pb:
    inconvenience -= parent[pa] * parent[pb]
  unite(parent, a, b)

for i in range(len(result)-1,-1,-1):
  print(result[i]) from sys import setrecursionlimit def find(parent, i):
  t = parent[i]
  if t < 0:
    return i
  t = find(parent, t)
  parent[i] = t
  return t find t = parent[i] t parent[i] parent i if t < 0:
    return i
   t < 0 t 0 return i i t = find(parent, t) t find(parent, t) find parent t parent[i] = t parent[i] parent i t return t t parent parent i i def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[j] += parent[i]
  parent[i] = j unite i = find(parent, i) i find(parent, i) find parent i j = find(parent, j) j find(parent, j) find parent j if i == j:
    return
   i == j i j return parent[j] += parent[i] parent[j] parent j parent[i] parent i parent[i] = j parent[i] parent i j parent parent i i j j setrecursionlimit(10**6) setrecursionlimit 10**6 10 6 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M [int(c) - 1 for c in input().split()] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [int(c) - 1 for c in input().split()] AB = [[int(c) - 1 for c in input().split()] for _ in range(M)] AB [[int(c) - 1 for c in input().split()] for _ in range(M)] parent = [-1]*N parent [-1]*N [-1] -1 N inconvenience = N*(N-1) // 2 inconvenience N*(N-1) // 2 N*(N-1) N N-1 N 1 2 result = [] result [] for a, b in AB[::-1]:
  result.append(inconvenience)
  pa, pb = find(parent, a), find(parent, b)
  if pa != pb:
    inconvenience -= parent[pa] * parent[pb]
  unite(parent, a, b) a b AB[::-1] AB ::-1 -1 result.append(inconvenience) result.append result append inconvenience pa, pb = find(parent, a), find(parent, b) pa find(parent, a) find parent a pb find(parent, b) find parent b if pa != pb:
    inconvenience -= parent[pa] * parent[pb]
   pa != pb pa pb inconvenience -= parent[pa] * parent[pb] inconvenience parent[pa] * parent[pb] parent[pa] parent pa parent[pb] parent pb unite(parent, a, b) unite parent a b for i in range(len(result)-1,-1,-1):
  print(result[i]) i range(len(result)-1,-1,-1) range len(result)-1 len(result) len result 1 -1 -1 print(result[i]) print result[i] result i parent = [-1]*N [-1]*N parent result = [] [] result N, M = map(int, input().split()) map(int, input().split()) N pa, pb = find(parent, a), find(parent, b) find(parent, a) pa inconvenience -= parent[pa] * parent[pb] parent[pa] * parent[pb] inconvenience M = map(int, input().split()) map(int, input().split()) M AB = [[int(c) - 1 for c in input().split()] for _ in range(M)] [[int(c) - 1 for c in input().split()] for _ in range(M)] AB def find(parent, i):
  t = parent[i]
  if t < 0:
    return i
  t = find(parent, t)
  parent[i] = t
  return t def find(parent, i):
  t = parent[i]
  if t < 0:
    return i
  t = find(parent, t)
  parent[i] = t
  return t find def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[j] += parent[i]
  parent[i] = j def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[j] += parent[i]
  parent[i] = j unite pb = find(parent, a), find(parent, b) find(parent, b) pb inconvenience = N*(N-1) // 2 N*(N-1) // 2 inconvenience
from sys import setrecursionlimit

def find(parent, i):
  t = parent[i]
  if t < 0:
    return i
  t = find(parent, t)
  parent[i] = t
  return t

def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[j] += parent[i]
  parent[i] = j

setrecursionlimit(10**6)

N, M = map(int, input().split())
AB = [[int(c) - 1 for c in input().split()] for _ in range(M)]

parent = [-1]*N
inconvenience = N*(N-1) // 2
result = []
for a, b in AB[::-1]:
  result.append(inconvenience)
  pa, pb = find(parent, a), find(parent, b)
  if pa != pb:
    inconvenience -= parent[pa] * parent[pb]
  unite(parent, a, b)

for i in range(len(result)-1,-1,-1):
  print(result[i])