# Original solution
import collections

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]


class UnitDict(dict):

    def __init__(self, iterable=None, wrapper=lambda x: x):
        super().__init__(self)
        self.wrapper = wrapper
        if iterable is not None:
            self.update(iterable)

    def __missing__(self, key):
        self[key] = self.wrapper(key)
        return self[key]


class UnionFind(object):

    def __init__(self, nodes=None):
        self.par = UnitDict(wrapper=lambda x: x)
        self.rank = collections.defaultdict(int)
        self.groups = UnitDict(wrapper=lambda x: {x})
        if nodes is not None:
            for node in nodes:
                _, _, _ = self.par[node], self.rank[node], self.groups[node]

    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r

    def are_same(self, node1, node2):
        return self.root(node1) == self.root(node2)

    def elements(self, node):
        return self.groups[self.root(node)]

    def size(self, node):
        return len(self.elements(node))

    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.groups[x].update(self.groups[y])
            self.groups[y].clear()
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def grouper(self):
        roots = [x for x in list(self.par.keys())]
        groups = []
        for root in roots:
            if list(self.elements(root)) not in groups:
                groups.append(list(self.elements(root)))
        return groups


islands = UnionFind(list(range(1, N)))
ans_list = []
last = int(N * (N-1) / 2)
ans_list.append(last)
for i in range(1, M):
    if islands.are_same(AB[-i][0], AB[-i][1]):
        ans_list.append(ans_list[-1])
    else:
        ans_list.append(ans_list[-1]-islands.size(AB[-i][0])*islands.size(AB[-i][1]))
    islands.unite(AB[-i][0], AB[-i][1])

for i in range(1, len(ans_list)+1):
    print((ans_list[-i]))

# Optimized solution
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]


class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

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

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

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

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


ans_list = []
graph = UnionFind(N)
last = N * (N-1) // 2
ans_list.append(last)
for i in range(M-1, -1, -1):
    a, b = AB[i]
    if graph.same(a-1, b-1):
        ans_list.append(ans_list[-1])
    else:
        ans_list.append(ans_list[-1] - graph.size(a-1) * graph.size(b-1))
    graph.unite(a-1, b-1)

for i in range(M-1, -1, -1):
    print((ans_list[i]))