import sys
input = lambda: sys.stdin.readline().rstrip()
import math

N, M = map(int, input().split())

def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]

def union(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    if parents[x] > parents[y]:
        x,y = y, x

    parents[x] += parents[y]
    parents[y] = x 

def same(x,y):
    return find(x) == find(y)

def parent_count(x):
    return -parents[find(x)]

edges = []
for i in range(M):
    a, b = map(int, input().split())
    edges.append((a-1,b-1))

ans = [0] * (M+1)
parents = [-1] * N
ans[-1] = N*(N-1)//2

for i in range(M-1, -1, -1):
    s, e = edges[i]
    if same(s, e):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - parent_count(s) * parent_count(e)
        union(s, e)
        
for i in range(1,M+1):
  	print(ans[i]) import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip import math math N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x] find if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x] parents[x] < 0 parents[x] parents x 0 return x x parents[x] = find(parents[x]) parents[x] parents x find(parents[x]) find parents[x] parents x return parents[x] parents[x] parents x x x def union(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    if parents[x] > parents[y]:
        x,y = y, x

    parents[x] += parents[y]
    parents[y] = x  union x = find(x) x find(x) find x y = find(y) y find(y) find y if x == y:
        return

     x == y x y return if parents[x] > parents[y]:
        x,y = y, x

     parents[x] > parents[y] parents[x] parents x parents[y] parents y x,y = y, x x y y x parents[x] += parents[y] parents[x] parents x parents[y] parents y parents[y] = x parents[y] parents y x x x y y def same(x,y):
    return find(x) == find(y) same return find(x) == find(y) find(x) == find(y) find(x) find x find(y) find y x x y y def parent_count(x):
    return -parents[find(x)] parent_count return -parents[find(x)] -parents[find(x)] parents[find(x)] parents find(x) find x x x edges = [] edges [] for i in range(M):
    a, b = map(int, input().split())
    edges.append((a-1,b-1)) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b edges.append((a-1,b-1)) edges.append edges append (a-1,b-1) a-1 a 1 b-1 b 1 ans = [0] * (M+1) ans [0] * (M+1) [0] 0 M+1 M 1 parents = [-1] * N parents [-1] * N [-1] -1 N ans[-1] = N*(N-1)//2 ans[-1] ans -1 N*(N-1)//2 N*(N-1) N N-1 N 1 2 for i in range(M-1, -1, -1):
    s, e = edges[i]
    if same(s, e):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - parent_count(s) * parent_count(e)
        union(s, e)
         i range(M-1, -1, -1) range M-1 M 1 -1 -1 s, e = edges[i] s edges[i] edges i e if same(s, e):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - parent_count(s) * parent_count(e)
        union(s, e)
         same(s, e) same s e ans[i] = ans[i+1] ans[i] ans i ans[i+1] ans i+1 i 1 ans[i] = ans[i+1] - parent_count(s) * parent_count(e) ans[i] ans i ans[i+1] - parent_count(s) * parent_count(e) ans[i+1] ans i+1 i 1 parent_count(s) * parent_count(e) parent_count(s) parent_count s parent_count(e) parent_count e union(s, e) union s e for i in range(1,M+1):
  	print(ans[i]) i range(1,M+1) range 1 M+1 M 1 print(ans[i]) print ans[i] ans i e = edges[i] edges[i] e input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input M = map(int, input().split()) map(int, input().split()) M parents = [-1] * N [-1] * N parents def union(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    if parents[x] > parents[y]:
        x,y = y, x

    parents[x] += parents[y]
    parents[y] = x  def union(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    if parents[x] > parents[y]:
        x,y = y, x

    parents[x] += parents[y]
    parents[y] = x  union a, b = map(int, input().split()) map(int, input().split()) a edges = [] [] edges N, M = map(int, input().split()) map(int, input().split()) N s, e = edges[i] edges[i] s def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x] def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x] find def same(x,y):
    return find(x) == find(y) def same(x,y):
    return find(x) == find(y) same def parent_count(x):
    return -parents[find(x)] def parent_count(x):
    return -parents[find(x)] parent_count ans = [0] * (M+1) [0] * (M+1) ans b = map(int, input().split()) map(int, input().split()) b
import sys
input = lambda: sys.stdin.readline().rstrip()
import math

N, M = map(int, input().split())

def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]

def union(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    if parents[x] > parents[y]:
        x,y = y, x

    parents[x] += parents[y]
    parents[y] = x 

def same(x,y):
    return find(x) == find(y)

def parent_count(x):
    return -parents[find(x)]

edges = []
for i in range(M):
    a, b = map(int, input().split())
    edges.append((a-1,b-1))

ans = [0] * (M+1)
parents = [-1] * N
ans[-1] = N*(N-1)//2

for i in range(M-1, -1, -1):
    s, e = edges[i]
    if same(s, e):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - parent_count(s) * parent_count(e)
        union(s, e)
        
for i in range(1,M+1):
  	print(ans[i])