class UnionFind:
    def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

    def get_num_trees(self):
        return len(self.heights)

    def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

    def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

    def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

    def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)


N, M = map(int, input().split())
AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a, b))

uf = UnionFind()
for i in range(1, N + 1):
    uf.add_node(i)

ans = [N * (N - 1) // 2]
for a, b in reversed(AB):
    if uf.find(a, b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uf.get_tree_size(a) * uf.get_tree_size(b))
    uf.union(a, b)

for i in range(M):
    print(ans[-2 - i]) class UnionFind:
    def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

    def get_num_trees(self):
        return len(self.heights)

    def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

    def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

    def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

    def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b) UnionFind def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

     __init__ self.data = {} self.data self data {} self.heights = {} self.heights self heights {} self.sizes = {} self.sizes self sizes {} self self def get_num_trees(self):
        return len(self.heights)

     get_num_trees return len(self.heights) len(self.heights) len self.heights self heights self self def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

     get_tree_size return self.sizes[self.get_root(a)] self.sizes[self.get_root(a)] self.sizes self sizes self.get_root(a) self.get_root self get_root a self self a a def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

     add_node self.data[a] = a self.data[a] self.data self data a a self.heights[a] = 1 self.heights[a] self.heights self heights a 1 self.sizes[a] = 1 self.sizes[a] self.sizes self sizes a 1 self self a a def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

     get_root nodes = [a] nodes [a] a while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
         nodes[-1] not in self.heights nodes[-1] nodes -1 self.heights self heights nodes.append(self.data[nodes[-1]]) nodes.append nodes append self.data[nodes[-1]] self.data self data nodes[-1] nodes -1 for x in nodes:
            self.data[x] = nodes[-1]
         x nodes self.data[x] = nodes[-1] self.data[x] self.data self data x nodes[-1] nodes -1 return nodes[-1] nodes[-1] nodes -1 self self a a def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

     union root_a = self.get_root(a) root_a self.get_root(a) self.get_root self get_root a root_b = self.get_root(b) root_b self.get_root(b) self.get_root self get_root b if root_a == root_b:
            return
         root_a == root_b root_a root_b return if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
         self.heights[root_a] > self.heights[root_b] self.heights[root_a] self.heights self heights root_a self.heights[root_b] self.heights self heights root_b a, b = b, a a b b a root_a, root_b = root_b, root_a root_a root_b root_b root_a self.data[root_a] = root_b self.data[root_a] self.data self data root_a root_b self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b]) self.heights[root_b] self.heights self heights root_b max(self.heights.pop(root_a) + 1, self.heights[root_b]) max self.heights.pop(root_a) + 1 self.heights.pop(root_a) self.heights.pop self.heights self heights pop root_a 1 self.heights[root_b] self.heights self heights root_b self.sizes[root_b] += self.sizes.pop(root_a) self.sizes[root_b] self.sizes self sizes root_b self.sizes.pop(root_a) self.sizes.pop self.sizes self sizes pop root_a self self a a b b def find(self, a, b):
        return self.get_root(a) == self.get_root(b) find return self.get_root(a) == self.get_root(b) self.get_root(a) == self.get_root(b) self.get_root(a) self.get_root self get_root a self.get_root(b) self.get_root self get_root b self self a a b b N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M AB = [] AB [] for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a, b)) _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b AB.append((a, b)) AB.append AB append (a, b) a b uf = UnionFind() uf UnionFind() UnionFind for i in range(1, N + 1):
    uf.add_node(i) i range(1, N + 1) range 1 N + 1 N 1 uf.add_node(i) uf.add_node uf add_node i ans = [N * (N - 1) // 2] ans [N * (N - 1) // 2] N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 for a, b in reversed(AB):
    if uf.find(a, b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uf.get_tree_size(a) * uf.get_tree_size(b))
    uf.union(a, b) a b reversed(AB) reversed AB if uf.find(a, b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uf.get_tree_size(a) * uf.get_tree_size(b))
     uf.find(a, b) uf.find uf find a b ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 ans.append(ans[-1] - uf.get_tree_size(a) * uf.get_tree_size(b)) ans.append ans append ans[-1] - uf.get_tree_size(a) * uf.get_tree_size(b) ans[-1] ans -1 uf.get_tree_size(a) * uf.get_tree_size(b) uf.get_tree_size(a) uf.get_tree_size uf get_tree_size a uf.get_tree_size(b) uf.get_tree_size uf get_tree_size b uf.union(a, b) uf.union uf union a b for i in range(M):
    print(ans[-2 - i]) i range(M) range M print(ans[-2 - i]) print ans[-2 - i] ans -2 - i -2 i uf = UnionFind() UnionFind() uf b = map(int, input().split()) map(int, input().split()) b M = map(int, input().split()) map(int, input().split()) M ans = [N * (N - 1) // 2] [N * (N - 1) // 2] ans AB = [] [] AB N, M = map(int, input().split()) map(int, input().split()) N a, b = map(int, input().split()) map(int, input().split()) a class UnionFind:
    def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

    def get_num_trees(self):
        return len(self.heights)

    def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

    def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

    def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

    def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b) class UnionFind:
    def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

    def get_num_trees(self):
        return len(self.heights)

    def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

    def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

    def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

    def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b) UnionFind
class UnionFind:
    def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

    def get_num_trees(self):
        return len(self.heights)

    def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

    def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

    def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

    def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)


N, M = map(int, input().split())
AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a, b))

uf = UnionFind()
for i in range(1, N + 1):
    uf.add_node(i)

ans = [N * (N - 1) // 2]
for a, b in reversed(AB):
    if uf.find(a, b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uf.get_tree_size(a) * uf.get_tree_size(b))
    uf.union(a, b)

for i in range(M):
    print(ans[-2 - i])