### BUGGY CODE ###

class UnionFindNode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        return "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})".format(self.group_id, self.parent_,
                                                                                         self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def parent(self):
        parent = self
        while parent.parent_:
            parent = parent.parent_
        return parent

    def find(self):
        parent = self.parent()
        return parent.group_id

    def size(self):
        parent = self.parent()
        return parent.size_

    def unite(self, unite_node):
        parent = self.parent()
        unite_parent = unite_node.parent()
        if parent.group_id != unite_parent.group_id:
            unite_parent.parent_ = parent
            parent.size_ = parent.size_ + unite_parent.size_


[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

node_list = [UnionFindNode(i) for i in range(N)]
combination_num = N * (N - 1) // 2
combination_list = [combination_num]

for bridge in bridge_list[:0:-1]:
    # print(bridge)
    if node_list[bridge[0]].find() != node_list[bridge[1]].find():
        combination_num = combination_num - node_list[bridge[0]].size() * node_list[bridge[1]].size()
        node_list[bridge[0]].unite(node_list[bridge[1]])
    combination_list.append(combination_num)
    # print(combination_num)

for value in combination_list[::-1]:
    print(value)

### FIXED CODE ###

class UnionFindNode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        return "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})".format(self.group_id, self.parent_,
                                                                                         self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def parent(self):
        parent = self
        while parent.parent_:
            parent = parent.parent_
        if not self.is_root():
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.parent()
        return parent.group_id

    def size(self):
        parent = self.parent()
        return parent.size_

    def unite(self, unite_node):
        parent = self.parent()
        unite_parent = unite_node.parent()
        if parent.group_id != unite_parent.group_id:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_


[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

node_list = [UnionFindNode(i) for i in range(N)]
combination_num = N * (N - 1) // 2
combination_list = [combination_num]

for bridge in bridge_list[:0:-1]:
    # print(bridge)
    if node_list[bridge[0]].find() != node_list[bridge[1]].find():
        combination_num = combination_num - node_list[bridge[0]].size() * node_list[bridge[1]].size()
        node_list[bridge[0]].unite(node_list[bridge[1]])
    combination_list.append(combination_num)
    # print(combination_num)

for value in combination_list[::-1]:
    print(value)