import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline
N, M = [int(i) for i in input().split()]
AB = [[int(i) - 1 for i in input().split()] for _ in range(M)]
ans = [N * (N - 1) // 2]

class UnionFind:
    def __init__(self, element_count):
        self.parent = [i for i in range(element_count)]
        self.counter = [1 for _ in range(element_count)]
    
    def root(self, index):
        root = index
        while root != self.parent[root]:
            root = self.parent[root]
        while index != root:
            index, self.parent[index] = self.parent[index], root
        return root
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.parent[y] = x
            self.counter[x] += self.counter[y]
            self.counter[y] = 0
    
    def count(self, index):
        return self.counter[self.root(index)]

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

uf = UnionFind(N)
for a, b in AB[:0:-1]:
    if not uf.is_same(a, b):
        ans.append(ans[-1] - uf.count(a) * uf.count(b))
        uf.unite(a, b)
    else:
        ans.append(ans[-1])
for a in ans[::-1]:
    print(a) import sys sys sys.setrecursionlimit(10000) sys.setrecursionlimit sys setrecursionlimit 10000 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N, M = [int(i) for i in input().split()] N [int(i) for i in input().split()] M [int(i) - 1 for i in input().split()] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [int(i) - 1 for i in input().split()] AB = [[int(i) - 1 for i in input().split()] for _ in range(M)] AB [[int(i) - 1 for i in input().split()] for _ in range(M)] ans = [N * (N - 1) // 2] ans [N * (N - 1) // 2] N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 class UnionFind:
    def __init__(self, element_count):
        self.parent = [i for i in range(element_count)]
        self.counter = [1 for _ in range(element_count)]
    
    def root(self, index):
        root = index
        while root != self.parent[root]:
            root = self.parent[root]
        while index != root:
            index, self.parent[index] = self.parent[index], root
        return root
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.parent[y] = x
            self.counter[x] += self.counter[y]
            self.counter[y] = 0
    
    def count(self, index):
        return self.counter[self.root(index)]

    def is_same(self, x, y):
        return self.root(x) == self.root(y) UnionFind def __init__(self, element_count):
        self.parent = [i for i in range(element_count)]
        self.counter = [1 for _ in range(element_count)]
    
     __init__ i for i in range(element_count) for i in range(element_count) i range(element_count) range element_count for i in range(element_count) i self.parent = [i for i in range(element_count)] self.parent self parent [i for i in range(element_count)] 1 for _ in range(element_count) for _ in range(element_count) _ range(element_count) range element_count for _ in range(element_count) 1 self.counter = [1 for _ in range(element_count)] self.counter self counter [1 for _ in range(element_count)] self self element_count element_count def root(self, index):
        root = index
        while root != self.parent[root]:
            root = self.parent[root]
        while index != root:
            index, self.parent[index] = self.parent[index], root
        return root
    
     root root = index root index while root != self.parent[root]:
            root = self.parent[root]
         root != self.parent[root] root self.parent[root] self.parent self parent root root = self.parent[root] root self.parent[root] self.parent self parent root while index != root:
            index, self.parent[index] = self.parent[index], root
         index != root index root index, self.parent[index] = self.parent[index], root index self.parent[index] self.parent self parent index self.parent[index] self.parent self parent index root return root root self self index index def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.parent[y] = x
            self.counter[x] += self.counter[y]
            self.counter[y] = 0
    
     unite x, y = self.root(x), self.root(y) x self.root(x) self.root self root x y self.root(y) self.root self root y if x != y:
            self.parent[y] = x
            self.counter[x] += self.counter[y]
            self.counter[y] = 0
    
     x != y x y self.parent[y] = x self.parent[y] self.parent self parent y x self.counter[x] += self.counter[y] self.counter[x] self.counter self counter x self.counter[y] self.counter self counter y self.counter[y] = 0 self.counter[y] self.counter self counter y 0 self self x x y y def count(self, index):
        return self.counter[self.root(index)]

     count return self.counter[self.root(index)] self.counter[self.root(index)] self.counter self counter self.root(index) self.root self root index self self index index def is_same(self, x, y):
        return self.root(x) == self.root(y) is_same return self.root(x) == self.root(y) self.root(x) == self.root(y) self.root(x) self.root self root x self.root(y) self.root self root y self self x x y y uf = UnionFind(N) uf UnionFind(N) UnionFind N for a, b in AB[:0:-1]:
    if not uf.is_same(a, b):
        ans.append(ans[-1] - uf.count(a) * uf.count(b))
        uf.unite(a, b)
    else:
        ans.append(ans[-1]) a b AB[:0:-1] AB :0:-1 0 -1 if not uf.is_same(a, b):
        ans.append(ans[-1] - uf.count(a) * uf.count(b))
        uf.unite(a, b)
    else:
        ans.append(ans[-1]) not uf.is_same(a, b) uf.is_same(a, b) uf.is_same uf is_same a b ans.append(ans[-1] - uf.count(a) * uf.count(b)) ans.append ans append ans[-1] - uf.count(a) * uf.count(b) ans[-1] ans -1 uf.count(a) * uf.count(b) uf.count(a) uf.count uf count a uf.count(b) uf.count uf count b uf.unite(a, b) uf.unite uf unite a b ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 for a in ans[::-1]:
    print(a) a ans[::-1] ans ::-1 -1 print(a) print a ans = [N * (N - 1) // 2] [N * (N - 1) // 2] ans class UnionFind:
    def __init__(self, element_count):
        self.parent = [i for i in range(element_count)]
        self.counter = [1 for _ in range(element_count)]
    
    def root(self, index):
        root = index
        while root != self.parent[root]:
            root = self.parent[root]
        while index != root:
            index, self.parent[index] = self.parent[index], root
        return root
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.parent[y] = x
            self.counter[x] += self.counter[y]
            self.counter[y] = 0
    
    def count(self, index):
        return self.counter[self.root(index)]

    def is_same(self, x, y):
        return self.root(x) == self.root(y) class UnionFind:
    def __init__(self, element_count):
        self.parent = [i for i in range(element_count)]
        self.counter = [1 for _ in range(element_count)]
    
    def root(self, index):
        root = index
        while root != self.parent[root]:
            root = self.parent[root]
        while index != root:
            index, self.parent[index] = self.parent[index], root
        return root
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.parent[y] = x
            self.counter[x] += self.counter[y]
            self.counter[y] = 0
    
    def count(self, index):
        return self.counter[self.root(index)]

    def is_same(self, x, y):
        return self.root(x) == self.root(y) UnionFind M = [int(i) for i in input().split()] [int(i) for i in input().split()] M AB = [[int(i) - 1 for i in input().split()] for _ in range(M)] [[int(i) - 1 for i in input().split()] for _ in range(M)] AB input = sys.stdin.readline sys.stdin.readline input N, M = [int(i) for i in input().split()] [int(i) for i in input().split()] N uf = UnionFind(N) UnionFind(N) uf
import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline
N, M = [int(i) for i in input().split()]
AB = [[int(i) - 1 for i in input().split()] for _ in range(M)]
ans = [N * (N - 1) // 2]

class UnionFind:
    def __init__(self, element_count):
        self.parent = [i for i in range(element_count)]
        self.counter = [1 for _ in range(element_count)]
    
    def root(self, index):
        root = index
        while root != self.parent[root]:
            root = self.parent[root]
        while index != root:
            index, self.parent[index] = self.parent[index], root
        return root
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.parent[y] = x
            self.counter[x] += self.counter[y]
            self.counter[y] = 0
    
    def count(self, index):
        return self.counter[self.root(index)]

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

uf = UnionFind(N)
for a, b in AB[:0:-1]:
    if not uf.is_same(a, b):
        ans.append(ans[-1] - uf.count(a) * uf.count(b))
        uf.unite(a, b)
    else:
        ans.append(ans[-1])
for a in ans[::-1]:
    print(a)