# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


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


def size(x):
    return -par[find(x)]



N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
Bridge = [tuple(map(int, input().split())) for _ in range(M)]
Bridge = Bridge[::-1]
Ans = []
ans = N * (N-1) // 2
for (a, b) in Bridge:
    Ans.append(ans)
    if find(a-1) != find(b-1):
        x = size(a-1)
        y = size(b-1)
    else:
        x = 0
        y = 0
    unite(a-1, b-1)
    ans -= x * y


Ans = Ans[::-1]

for an in Ans:
    print(an)
 def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] find if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] par[x] < 0 par[x] par x 0 return x x par[x] = find(par[x]) par[x] par x find(par[x]) find par[x] par x return par[x] par[x] par x x x def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True unite x = find(x) x find(x) find x y = find(y) y find(y) find y if x == y:
        return False
     x == y x y return False False if par[x] > par[y]:
        x, y = y, x
     par[x] > par[y] par[x] par x par[y] par y x, y = y, x x y y x par[x] += par[y] par[x] par x par[y] par y par[y] = x par[y] par y x return True True 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 size(x):
    return -par[find(x)] size return -par[find(x)] -par[find(x)] par[find(x)] par find(x) find x x x N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M par = [-1] * N par [-1] * N [-1] -1 N tuple(map(int, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split Bridge = [tuple(map(int, input().split())) for _ in range(M)] Bridge [tuple(map(int, input().split())) for _ in range(M)] Bridge = Bridge[::-1] Bridge Bridge[::-1] Bridge ::-1 -1 Ans = [] Ans [] ans = N * (N-1) // 2 ans N * (N-1) // 2 N * (N-1) N N-1 N 1 2 for (a, b) in Bridge:
    Ans.append(ans)
    if find(a-1) != find(b-1):
        x = size(a-1)
        y = size(b-1)
    else:
        x = 0
        y = 0
    unite(a-1, b-1)
    ans -= x * y (a, b) a b Bridge Ans.append(ans) Ans.append Ans append ans if find(a-1) != find(b-1):
        x = size(a-1)
        y = size(b-1)
    else:
        x = 0
        y = 0
     find(a-1) != find(b-1) find(a-1) find a-1 a 1 find(b-1) find b-1 b 1 x = size(a-1) x size(a-1) size a-1 a 1 y = size(b-1) y size(b-1) size b-1 b 1 x = 0 x 0 y = 0 y 0 unite(a-1, b-1) unite a-1 a 1 b-1 b 1 ans -= x * y ans x * y x y Ans = Ans[::-1] Ans Ans[::-1] Ans ::-1 -1 for an in Ans:
    print(an) an Ans print(an) print an x = 0 0 x ans -= x * y x * y ans def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True unite y = 0 0 y Bridge = [tuple(map(int, input().split())) for _ in range(M)] [tuple(map(int, input().split())) for _ in range(M)] Bridge def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] find def same(x, y):
    return find(x) == find(y) def same(x, y):
    return find(x) == find(y) same M = map(int, input().split()) map(int, input().split()) M Ans = Ans[::-1] Ans[::-1] Ans ans = N * (N-1) // 2 N * (N-1) // 2 ans Ans = [] [] Ans x = size(a-1) size(a-1) x def size(x):
    return -par[find(x)] def size(x):
    return -par[find(x)] size par = [-1] * N [-1] * N par Bridge = Bridge[::-1] Bridge[::-1] Bridge y = size(b-1) size(b-1) y N, M = map(int, input().split()) map(int, input().split()) N
# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


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


def size(x):
    return -par[find(x)]



N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
Bridge = [tuple(map(int, input().split())) for _ in range(M)]
Bridge = Bridge[::-1]
Ans = []
ans = N * (N-1) // 2
for (a, b) in Bridge:
    Ans.append(ans)
    if find(a-1) != find(b-1):
        x = size(a-1)
        y = size(b-1)
    else:
        x = 0
        y = 0
    unite(a-1, b-1)
    ans -= x * y


Ans = Ans[::-1]

for an in Ans:
    print(an)

