import sys

sys.setrecursionlimit(100000)





class UnionFind():

    def __init__(self, n):

        self.par = [i for i in range(n)]

        self.size = [1 for _ in range(n)]



    def find(self, x):

        if self.par[x] != x:

            self.par[x] = self.find(self.par[x]) # contraction

        return self.par[x]



    def unite(self, x, y):

        x = self.find(x)

        y = self.find(y)

        if not self.same(x, y):

            self.size[y] += self.size[x]

        self.par[x] = y



    def same(self, x, y):

        return self.find(x) == self.find(y)





n, m = list(map(int, input().split()))

edge = [list([int(x) - 1 for x in input().split()]) for _ in range(m)]



uf = UnionFind(n)

ans = n * (n-1) // 2

anss = []

for i in reversed(list(range(m))):

    anss.append(ans)

    # print(uf.par)

    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])

    a, b = edge[i]

    if not uf.same(a, b):

        ans -= uf.size[uf.find(a)] * uf.size[uf.find(b)]

    # print(i, a, b)



    uf.unite(a, b)



for i in reversed(list(range(m))):

    print((anss[i]))

class UnionFind():

    def __init__(self, n):

        self.par = [-1 for i in range(n)]



    def root(self, x):

        if self.par[x] < 0:

            return x

        else:

            self.par[x] = self.root(self.par[x]) # contraction

            return self.par[x]



    def unite(self, x, y):

        x = self.root(x)

        y = self.root(y)

        if x == y:

            return False

        if self.par[x] > self.par[y]:

            x, y = y, x

        self.par[x] += self.par[y]

        self.par[y] = x

        return True



    def same(self, x, y):

        return self.root(x) == self.root(y)



    def size(self, x):

        return - self.par[self.root(x)]





n, m = list(map(int, input().split()))

edge = [list([int(x) - 1 for x in input().split()]) for _ in range(m)]



uf = UnionFind(n)

ans = n * (n-1) // 2

anss = []

for i in reversed(list(range(m))):

    anss.append(ans)

    # print(uf.par)

    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])

    a, b = edge[i]

    if not uf.same(a, b):

        ans -= uf.size(a) * uf.size(b)

    # print(i, a, b)



    uf.unite(a, b)



for i in reversed(list(range(m))):

    print((anss[i]))

import sys

sys.setrecursionlimit(100000)


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])  # contraction
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.same(x, y):
            self.size[y] += self.size[x]
        self.par[x] = y

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


n, m = list(map(int, input().split()))
edge = [list([int(x) - 1 for x in input().split()]) for _ in range(m)]
uf = UnionFind(n)
ans = n * (n - 1) // 2
anss = []
for i in reversed(list(range(m))):
    anss.append(ans)
    # print(uf.par)
    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])
    a, b = edge[i]
    if not uf.same(a, b):
        ans -= uf.size[uf.find(a)] * uf.size[uf.find(b)]
    # print(i, a, b)
    uf.unite(a, b)
for i in reversed(list(range(m))):
    print((anss[i]))

class UnionFind:
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])  # contraction
            return self.par[x]

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

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]


n, m = list(map(int, input().split()))
edge = [list([int(x) - 1 for x in input().split()]) for _ in range(m)]
uf = UnionFind(n)
ans = n * (n - 1) // 2
anss = []
for i in reversed(list(range(m))):
    anss.append(ans)
    # print(uf.par)
    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])
    a, b = edge[i]
    if not uf.same(a, b):
        ans -= uf.size(a) * uf.size(b)
    # print(i, a, b)
    uf.unite(a, b)
for i in reversed(list(range(m))):
    print((anss[i]))

-import sys - -sys.setrecursionlimit(100000) - - -        self.par = [i for i in range(n)] -        self.size = [1 for _ in range(n)] +        self.par = [-1 for i in range(n)] -    def find(self, x): -        if self.par[x] != x: -            self.par[x] = self.find(self.par[x])  # contraction -        return self.par[x] +    def root(self, x): +        if self.par[x] < 0: +            return x +        else: +            self.par[x] = self.root(self.par[x])  # contraction +            return self.par[x] -        x = self.find(x) -        y = self.find(y) -        if not self.same(x, y): -            self.size[y] += self.size[x] -        self.par[x] = y +        x = self.root(x) +        y = self.root(y) +        if x == y: +            return False +        if self.par[x] > self.par[y]: +            x, y = y, x +        self.par[x] += self.par[y] +        self.par[y] = x +        return True -        return self.find(x) == self.find(y) +        return self.root(x) == self.root(y) + +    def size(self, x): +        return -self.par[self.root(x)] -        ans -= uf.size[uf.find(a)] * uf.size[uf.find(b)] +        ans -= uf.size(a) * uf.size(b)