# solution

import sys
input = sys.stdin.readline

def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

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

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

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

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

par = [0] * N
for i in range(N):
    par[i] = i

rank = [1] * N
size = [1] * N
res = []

edge2 = [[0] for i in range(M)]
for i in range(M):
    edge2[i] = list(map(int, input().split()))

edge = [[0] for i in range(M)]
for i in range(M):
    edge[i] = [edge2[M - 1 - i][0] - 1, edge2[M - 1 - i][1] - 1]

for i in range(M):
    fi = find(edge[i][0])
    se = find(edge[i][1])

    if fi == se:
        res.append(0)
    else:
        res.append(size[fi] * size[se])
        unite(fi, se)

ans = 0
for i in range(M):
    ans += res[M - 1 - i]
    print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x]) find if par[x] == x:
        return x
    else:
        return find(par[x]) par[x] == x par[x] par x x return x x return find(par[x]) find(par[x]) find par[x] par x x x def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1 unite x = find(x) x find(x) find x y = find(y) y find(y) find y if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1 x != y x y if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1 rank[x] < rank[y] rank[x] rank x rank[y] rank y par[x] = y par[x] par x y size[y] += size[x] size[y] size y size[x] size x par[y] = x par[y] par y x size[x] += size[y] size[x] size x size[y] size y if rank[x] == rank[y]:
                rank[x] += 1 rank[x] == rank[y] rank[x] rank x rank[y] rank y rank[x] += 1 rank[x] rank x 1 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 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M par = [0] * N par [0] * N [0] 0 N for i in range(N):
    par[i] = i i range(N) range N par[i] = i par[i] par i i rank = [1] * N rank [1] * N [1] 1 N size = [1] * N size [1] * N [1] 1 N res = [] res [] [0] for i in range(M) for i in range(M) i range(M) range M for i in range(M) [0] 0 edge2 = [[0] for i in range(M)] edge2 [[0] for i in range(M)] for i in range(M):
    edge2[i] = list(map(int, input().split())) i range(M) range M edge2[i] = list(map(int, input().split())) edge2[i] edge2 i list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split [0] for i in range(M) for i in range(M) i range(M) range M for i in range(M) [0] 0 edge = [[0] for i in range(M)] edge [[0] for i in range(M)] for i in range(M):
    edge[i] = [edge2[M - 1 - i][0] - 1, edge2[M - 1 - i][1] - 1] i range(M) range M edge[i] = [edge2[M - 1 - i][0] - 1, edge2[M - 1 - i][1] - 1] edge[i] edge i [edge2[M - 1 - i][0] - 1, edge2[M - 1 - i][1] - 1] edge2[M - 1 - i][0] - 1 edge2[M - 1 - i][0] [M - 1 - i] edge2 M - 1 - i M - 1 M 1 i 0 1 edge2[M - 1 - i][1] - 1 edge2[M - 1 - i][1] [M - 1 - i] edge2 M - 1 - i M - 1 M 1 i 1 1 for i in range(M):
    fi = find(edge[i][0])
    se = find(edge[i][1])

    if fi == se:
        res.append(0)
    else:
        res.append(size[fi] * size[se])
        unite(fi, se) i range(M) range M fi = find(edge[i][0]) fi find(edge[i][0]) find edge[i][0] [i] edge i 0 se = find(edge[i][1]) se find(edge[i][1]) find edge[i][1] [i] edge i 1 if fi == se:
        res.append(0)
    else:
        res.append(size[fi] * size[se])
        unite(fi, se) fi == se fi se res.append(0) res.append res append 0 res.append(size[fi] * size[se]) res.append res append size[fi] * size[se] size[fi] size fi size[se] size se unite(fi, se) unite fi se ans = 0 ans 0 for i in range(M):
    ans += res[M - 1 - i]
    print(ans) i range(M) range M ans += res[M - 1 - i] ans res[M - 1 - i] res M - 1 - i M - 1 M 1 i print(ans) print ans edge2 = [[0] for i in range(M)] [[0] for i in range(M)] edge2 size = [1] * N [1] * N size se = find(edge[i][1]) find(edge[i][1]) se def same(x, y):
    return find(x) == find(y) def same(x, y):
    return find(x) == find(y) same fi = find(edge[i][0]) find(edge[i][0]) fi par = [0] * N [0] * N par def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1 def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1 unite ans = 0 0 ans N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M res = [] [] res edge = [[0] for i in range(M)] [[0] for i in range(M)] edge def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x]) def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x]) find input = sys.stdin.readline sys.stdin.readline input rank = [1] * N [1] * N rank ans += res[M - 1 - i] res[M - 1 - i] ans
# solution

import sys
input = sys.stdin.readline

def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

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

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

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

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

par = [0] * N
for i in range(N):
    par[i] = i

rank = [1] * N
size = [1] * N
res = []

edge2 = [[0] for i in range(M)]
for i in range(M):
    edge2[i] = list(map(int, input().split()))

edge = [[0] for i in range(M)]
for i in range(M):
    edge[i] = [edge2[M - 1 - i][0] - 1, edge2[M - 1 - i][1] - 1]

for i in range(M):
    fi = find(edge[i][0])
    se = find(edge[i][1])

    if fi == se:
        res.append(0)
    else:
        res.append(size[fi] * size[se])
        unite(fi, se)

ans = 0
for i in range(M):
    ans += res[M - 1 - i]
    print(ans)