n,m = map(int,input().split())
a = [0]*m
b = [0]*m
for i in range(m):
  a[i], b[i] = map(int,input().split())

d = list(range(n+1))
g = [[i] for i in range(n+1)]

c = n*(n-1)//2
ans = [c]

for i in range(1,m)[::-1]:
  x = d[a[i]]
  y = d[b[i]]
  x,y = max(x,y),min(x,y)
  if x > y:
    c -= len(g[x])*len(g[y])
    for i in g[y]:
      d[i] = x
    g[x] += g[y]
  ans.append(c)

for t in ans[::-1]:
  print(t) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a = [0]*m a [0]*m [0] 0 m b = [0]*m b [0]*m [0] 0 m for i in range(m):
  a[i], b[i] = map(int,input().split()) i range(m) range m a[i], b[i] = map(int,input().split()) a[i] a i map(int,input().split()) map int input().split() ().split () input split b[i] b i d = list(range(n+1)) d list(range(n+1)) list range(n+1) range n+1 n 1 [i] for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) [i] i g = [[i] for i in range(n+1)] g [[i] for i in range(n+1)] c = n*(n-1)//2 c n*(n-1)//2 n*(n-1) n n-1 n 1 2 ans = [c] ans [c] c for i in range(1,m)[::-1]:
  x = d[a[i]]
  y = d[b[i]]
  x,y = max(x,y),min(x,y)
  if x > y:
    c -= len(g[x])*len(g[y])
    for i in g[y]:
      d[i] = x
    g[x] += g[y]
  ans.append(c) i range(1,m)[::-1] (1,m) range 1 m ::-1 -1 x = d[a[i]] x d[a[i]] d a[i] a i y = d[b[i]] y d[b[i]] d b[i] b i x,y = max(x,y),min(x,y) x max(x,y) max x y y min(x,y) min x y if x > y:
    c -= len(g[x])*len(g[y])
    for i in g[y]:
      d[i] = x
    g[x] += g[y]
   x > y x y c -= len(g[x])*len(g[y]) c len(g[x])*len(g[y]) len(g[x]) len g[x] g x len(g[y]) len g[y] g y for i in g[y]:
      d[i] = x
     i g[y] g y d[i] = x d[i] d i x g[x] += g[y] g[x] g x g[y] g y ans.append(c) ans.append ans append c for t in ans[::-1]:
  print(t) t ans[::-1] ans ::-1 -1 print(t) print t d = list(range(n+1)) list(range(n+1)) d x = d[a[i]] d[a[i]] x x,y = max(x,y),min(x,y) max(x,y) x g = [[i] for i in range(n+1)] [[i] for i in range(n+1)] g c -= len(g[x])*len(g[y]) len(g[x])*len(g[y]) c c = n*(n-1)//2 n*(n-1)//2 c m = map(int,input().split()) map(int,input().split()) m ans = [c] [c] ans y = d[b[i]] d[b[i]] y y = max(x,y),min(x,y) min(x,y) y b = [0]*m [0]*m b n,m = map(int,input().split()) map(int,input().split()) n a = [0]*m [0]*m a
n,m = map(int,input().split())
a = [0]*m
b = [0]*m
for i in range(m):
  a[i], b[i] = map(int,input().split())

d = list(range(n+1))
g = [[i] for i in range(n+1)]

c = n*(n-1)//2
ans = [c]

for i in range(1,m)[::-1]:
  x = d[a[i]]
  y = d[b[i]]
  x,y = max(x,y),min(x,y)
  if x > y:
    c -= len(g[x])*len(g[y])
    for i in g[y]:
      d[i] = x
    g[x] += g[y]
  ans.append(c)

for t in ans[::-1]:
  print(t)
