import sys
input = lambda: sys.stdin.readline().rstrip()
from itertools import accumulate

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

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

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

    if x == y:
        return
    if x > y:
        x, y = y, x

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

def same(x,y):

    return find(x) == find(y)

def count_root(x):

    return parents[find(x)]

edges = []

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a,b))
parents = [-1] * N
ans = [0] * M
ans[-1] = N * (N-1) // 2

for i in range(M-1, 0, -1):
    c1, c2 = edges[i]

    if not same(c1, c2):
        ans[i-1] = ans[i] - count_root(c1) * count_root(c2)
        union(c1,c2)
    else:
        ans[i-1] = ans[i]     

for a in ans:
    print(a) 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 from itertools import accumulate 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
    parents[x] = find(parents[x])
    return parents[x]     find if parents[x] < 0:
        return 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 x > 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 x > y:
        x, y = y, x

     x > y x 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 count_root(x):

    return parents[find(x)] count_root return 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())
    a -= 1
    b -= 1
    edges.append((a,b)) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b a -= 1 a 1 b -= 1 b 1 edges.append((a,b)) edges.append edges append (a,b) a b parents = [-1] * N parents [-1] * N [-1] -1 N ans = [0] * M ans [0] * M [0] 0 M 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, 0, -1):
    c1, c2 = edges[i]

    if not same(c1, c2):
        ans[i-1] = ans[i] - count_root(c1) * count_root(c2)
        union(c1,c2)
    else:
        ans[i-1] = ans[i]      i range(M-1, 0, -1) range M-1 M 1 0 -1 c1, c2 = edges[i] c1 edges[i] edges i c2 if not same(c1, c2):
        ans[i-1] = ans[i] - count_root(c1) * count_root(c2)
        union(c1,c2)
    else:
        ans[i-1] = ans[i]      not same(c1, c2) same(c1, c2) same c1 c2 ans[i-1] = ans[i] - count_root(c1) * count_root(c2) ans[i-1] ans i-1 i 1 ans[i] - count_root(c1) * count_root(c2) ans[i] ans i count_root(c1) * count_root(c2) count_root(c1) count_root c1 count_root(c2) count_root c2 union(c1,c2) union c1 c2 ans[i-1] = ans[i] ans[i-1] ans i-1 i 1 ans[i] ans i for a in ans:
    print(a) a ans print(a) print a N, M = map(int, input().split()) map(int, input().split()) N a -= 1 1 a M = map(int, input().split()) map(int, input().split()) M def same(x,y):

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

    return find(x) == find(y) same input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input parents = [-1] * N [-1] * N parents c1, c2 = edges[i] edges[i] c1 a, b = map(int, input().split()) map(int, input().split()) a def count_root(x):

    return parents[find(x)] def count_root(x):

    return parents[find(x)] count_root c2 = edges[i] edges[i] c2 edges = [] [] edges b = map(int, input().split()) map(int, input().split()) b b -= 1 1 b ans = [0] * M [0] * M ans def union(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return
    if x > 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 x > y:
        x, y = y, x

    parents[x] += parents[y]
    parents[y] = x     union def find(x):
    if parents[x] < 0:
        return x
    parents[x] = find(parents[x])
    return parents[x]     def find(x):
    if parents[x] < 0:
        return x
    parents[x] = find(parents[x])
    return parents[x]     find
import sys
input = lambda: sys.stdin.readline().rstrip()
from itertools import accumulate

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

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

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

    if x == y:
        return
    if x > y:
        x, y = y, x

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

def same(x,y):

    return find(x) == find(y)

def count_root(x):

    return parents[find(x)]

edges = []

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a,b))
parents = [-1] * N
ans = [0] * M
ans[-1] = N * (N-1) // 2

for i in range(M-1, 0, -1):
    c1, c2 = edges[i]

    if not same(c1, c2):
        ans[i-1] = ans[i] - count_root(c1) * count_root(c2)
        union(c1,c2)
    else:
        ans[i-1] = ans[i]     

for a in ans:
    print(a)