class UnionFind:

    def __init__(self, n):
        self.roots = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def find_root(self, node):
        parent = self.roots[node]
        if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

    def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

    def size(self, node):
        root = self.find_root(node)
        return self.sizes[root]


def main():
    N, M = list(map(int, input().split(' ')))
    bridges = list()
    for _ in range(M):
        A, B = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        bridges.append((A, B))
    bridges.reverse()
    tree = UnionFind(N)
    convenience = [0]
    for b in bridges[:-1]:
        one, other = b
        c = convenience[-1]
        if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
        convenience.append(c)
        tree.union(one, other)
    convenience.reverse()
    max_c = N * (N - 1) // 2
    for c in convenience:
        print(max_c - c)


if __name__ == '__main__':
    main() class UnionFind:

    def __init__(self, n):
        self.roots = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def find_root(self, node):
        parent = self.roots[node]
        if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

    def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

    def size(self, node):
        root = self.find_root(node)
        return self.sizes[root] UnionFind def __init__(self, n):
        self.roots = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

     __init__ i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.roots = [i for i in range(n)] self.roots self roots [i for i in range(n)] 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 self.ranks = [0 for _ in range(n)] self.ranks self ranks [0 for _ in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 self.sizes = [1 for _ in range(n)] self.sizes self sizes [1 for _ in range(n)] self self n n def find_root(self, node):
        parent = self.roots[node]
        if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

     find_root parent = self.roots[node] parent self.roots[node] self.roots self roots node if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

     node == parent node parent return node node root = self.find_root(parent) root self.find_root(parent) self.find_root self find_root parent self.roots[node] = root self.roots[node] self.roots self roots node root return root root self self node node def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

     union one_root = self.find_root(one) one_root self.find_root(one) self.find_root self find_root one other_root = self.find_root(other) other_root self.find_root(other) self.find_root self find_root other if one_root == other_root:
            return
         one_root == other_root one_root other_root return if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

     self.ranks[one_root] < self.ranks[other_root] self.ranks[one_root] self.ranks self ranks one_root self.ranks[other_root] self.ranks self ranks other_root self.roots[one_root] = other_root self.roots[one_root] self.roots self roots one_root other_root self.sizes[other_root] += self.sizes[one_root] self.sizes[other_root] self.sizes self sizes other_root self.sizes[one_root] self.sizes self sizes one_root self.roots[other_root] = one_root self.roots[other_root] self.roots self roots other_root one_root self.sizes[one_root] += self.sizes[other_root] self.sizes[one_root] self.sizes self sizes one_root self.sizes[other_root] self.sizes self sizes other_root if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

     self.ranks[one_root] == self.ranks[other_root] self.ranks[one_root] self.ranks self ranks one_root self.ranks[other_root] self.ranks self ranks other_root self.ranks[one_root] += 1 self.ranks[one_root] self.ranks self ranks one_root 1 self self one one other other def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

     is_same_group one_root = self.find_root(one) one_root self.find_root(one) self.find_root self find_root one other_root = self.find_root(other) other_root self.find_root(other) self.find_root self find_root other return one_root == other_root one_root == other_root one_root other_root self self one one other other def size(self, node):
        root = self.find_root(node)
        return self.sizes[root] size root = self.find_root(node) root self.find_root(node) self.find_root self find_root node return self.sizes[root] self.sizes[root] self.sizes self sizes root self self node node def main():
    N, M = list(map(int, input().split(' ')))
    bridges = list()
    for _ in range(M):
        A, B = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        bridges.append((A, B))
    bridges.reverse()
    tree = UnionFind(N)
    convenience = [0]
    for b in bridges[:-1]:
        one, other = b
        c = convenience[-1]
        if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
        convenience.append(c)
        tree.union(one, other)
    convenience.reverse()
    max_c = N * (N - 1) // 2
    for c in convenience:
        print(max_c - c) main N, M = list(map(int, input().split(' '))) N list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' M bridges = list() bridges list() list for _ in range(M):
        A, B = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        bridges.append((A, B))
     _ range(M) range M A, B = list(map(int, input().split(' '))) A list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' B A -= 1 A 1 B -= 1 B 1 bridges.append((A, B)) bridges.append bridges append (A, B) A B bridges.reverse() bridges.reverse bridges reverse tree = UnionFind(N) tree UnionFind(N) UnionFind N convenience = [0] convenience [0] 0 for b in bridges[:-1]:
        one, other = b
        c = convenience[-1]
        if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
        convenience.append(c)
        tree.union(one, other)
     b bridges[:-1] bridges :-1 -1 one, other = b one b other c = convenience[-1] c convenience[-1] convenience -1 if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
         not tree.is_same_group(one, other) tree.is_same_group(one, other) tree.is_same_group tree is_same_group one other one_size = tree.size(one) one_size tree.size(one) tree.size tree size one other_size = tree.size(other) other_size tree.size(other) tree.size tree size other c += one_size * other_size c one_size * other_size one_size other_size convenience.append(c) convenience.append convenience append c tree.union(one, other) tree.union tree union one other convenience.reverse() convenience.reverse convenience reverse max_c = N * (N - 1) // 2 max_c N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 for c in convenience:
        print(max_c - c) c convenience print(max_c - c) print max_c - c max_c c if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main class UnionFind:

    def __init__(self, n):
        self.roots = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def find_root(self, node):
        parent = self.roots[node]
        if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

    def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

    def size(self, node):
        root = self.find_root(node)
        return self.sizes[root] class UnionFind:

    def __init__(self, n):
        self.roots = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def find_root(self, node):
        parent = self.roots[node]
        if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

    def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

    def size(self, node):
        root = self.find_root(node)
        return self.sizes[root] UnionFind def main():
    N, M = list(map(int, input().split(' ')))
    bridges = list()
    for _ in range(M):
        A, B = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        bridges.append((A, B))
    bridges.reverse()
    tree = UnionFind(N)
    convenience = [0]
    for b in bridges[:-1]:
        one, other = b
        c = convenience[-1]
        if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
        convenience.append(c)
        tree.union(one, other)
    convenience.reverse()
    max_c = N * (N - 1) // 2
    for c in convenience:
        print(max_c - c) def main():
    N, M = list(map(int, input().split(' ')))
    bridges = list()
    for _ in range(M):
        A, B = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        bridges.append((A, B))
    bridges.reverse()
    tree = UnionFind(N)
    convenience = [0]
    for b in bridges[:-1]:
        one, other = b
        c = convenience[-1]
        if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
        convenience.append(c)
        tree.union(one, other)
    convenience.reverse()
    max_c = N * (N - 1) // 2
    for c in convenience:
        print(max_c - c) main
class UnionFind:

    def __init__(self, n):
        self.roots = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def find_root(self, node):
        parent = self.roots[node]
        if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

    def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

    def size(self, node):
        root = self.find_root(node)
        return self.sizes[root]


def main():
    N, M = list(map(int, input().split(' ')))
    bridges = list()
    for _ in range(M):
        A, B = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        bridges.append((A, B))
    bridges.reverse()
    tree = UnionFind(N)
    convenience = [0]
    for b in bridges[:-1]:
        one, other = b
        c = convenience[-1]
        if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
        convenience.append(c)
        tree.union(one, other)
    convenience.reverse()
    max_c = N * (N - 1) // 2
    for c in convenience:
        print(max_c - c)


if __name__ == '__main__':
    main()