# Union Find 木
from sys import setrecursionlimit

#要素xが属するグループの根を返す
def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t

#xとyの木を併合
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)]
# print(AB[::-1])

parent = [-1] * N
inconvenience = N * (N - 1) // 2
result = []
for a, b in AB[::-1]:
    # print(inconvenience)
    # print(parent)
    result.append(inconvenience)

    #a, bが属するグループの根をparentに記録する
    pa, pb = find(parent, a), find(parent, b)
    # print(pa, pb)
    # print(parent[pa], parent[pb], parent[pa] * parent[pb])

    #
    if pa != pb:
        inconvenience -= parent[pa] * parent[pb]

    #取り出した辺を併合
    unite(parent, a, b)

print(*result[::-1]) 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

#xとyの木を併合 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]:
    # print(inconvenience)
    # print(parent)
    result.append(inconvenience)

    #a, bが属するグループの根をparentに記録する
    pa, pb = find(parent, a), find(parent, b)
    # print(pa, pb)
    # print(parent[pa], parent[pb], parent[pa] * parent[pb])

    #
    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 print(*result[::-1]) print *result[::-1] result[::-1] result ::-1 -1 pb = find(parent, a), find(parent, b) find(parent, b) pb parent = [-1] * N [-1] * N parent M = map(int, input().split()) map(int, input().split()) M inconvenience = N * (N - 1) // 2 N * (N - 1) // 2 inconvenience inconvenience -= parent[pa] * parent[pb] parent[pa] * parent[pb] inconvenience N, M = map(int, input().split()) map(int, input().split()) N result = [] [] result pa, pb = find(parent, a), find(parent, b) find(parent, a) pa 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 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 def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t

#xとyの木を併合 def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t

#xとyの木を併合 find
# Union Find 木
from sys import setrecursionlimit

#要素xが属するグループの根を返す
def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t

#xとyの木を併合
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)]
# print(AB[::-1])

parent = [-1] * N
inconvenience = N * (N - 1) // 2
result = []
for a, b in AB[::-1]:
    # print(inconvenience)
    # print(parent)
    result.append(inconvenience)

    #a, bが属するグループの根をparentに記録する
    pa, pb = find(parent, a), find(parent, b)
    # print(pa, pb)
    # print(parent[pa], parent[pb], parent[pa] * parent[pb])

    #
    if pa != pb:
        inconvenience -= parent[pa] * parent[pb]

    #取り出した辺を併合
    unite(parent, a, b)

print(*result[::-1])
