
class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * N
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
    def get_size(self, a):
        return self.size[self.root(a)]

N,M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]

ans = []


now = N*(N-1) // 2
ans.append(now)

uf = UnionFind(N)
for i in reversed(range(M)):

    if i == 0: break 
    a,b = AB[i]
    a,b = a-1, b-1

    if not uf.is_same(a,b):
        #print(now, uf.get_size(a) , uf.get_size(b), uf.size)
        now -= uf.get_size(a) * uf.get_size(b)
        #print("---", now)
        uf.unite(a,b)
        #uf.root(a)
        #uf.root(b)

    ans.append(now)

for i in reversed(range(len(ans))):
    print(ans[i]) class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * N
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
    def get_size(self, a):
        return self.size[self.root(a)] UnionFind def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * 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.parent = [i for i in range(N)] self.parent self parent [i for i in range(N)] self.rank = [0] * N self.rank self rank [0] * N [0] 0 N self.count = 0 self.count self count 0 self.size = [1] * N self.size self size [1] * N [1] 1 N self self N N def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
     root if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
     self.parent[a] == a self.parent[a] self.parent self parent a a return a a self.parent[a] = self.root(self.parent[a]) self.parent[a] self.parent self parent a self.root(self.parent[a]) self.root self root self.parent[a] self.parent self parent a return self.parent[a] self.parent[a] self.parent self parent a self self a a def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
     is_same return self.root(a) == self.root(b) self.root(a) == self.root(b) self.root(a) self.root self root a self.root(b) self.root self root b self self a a b b def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
     unite ra = self.root(a) ra self.root(a) self.root self root a rb = self.root(b) rb self.root(b) self.root self root b if ra == rb:
            return 
         ra == rb ra rb return if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
         self.rank[ra] < self.rank[rb] self.rank[ra] self.rank self rank ra self.rank[rb] self.rank self rank rb self.size[rb] += self.size[ra] self.size[rb] self.size self size rb self.size[ra] self.size self size ra self.parent[ra] = rb self.parent[ra] self.parent self parent ra rb self.size[ra] += self.size[rb] self.size[ra] self.size self size ra self.size[rb] self.size self size rb self.parent[rb] = ra self.parent[rb] self.parent self parent rb ra if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
         self.rank[ra] == self.rank[rb] self.rank[ra] self.rank self rank ra self.rank[rb] self.rank self rank rb self.rank[ra] += 1 self.rank[ra] self.rank self rank ra 1 self.count += 1 self.count self count 1 self self a a b b def get_size(self, a):
        return self.size[self.root(a)] get_size return self.size[self.root(a)] self.size[self.root(a)] self.size self size self.root(a) self.root self root a self self a a N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M tuple(map(int, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split AB = [tuple(map(int, input().split())) for _ in range(M)] AB [tuple(map(int, input().split())) for _ in range(M)] ans = [] ans [] now = N*(N-1) // 2 now N*(N-1) // 2 N*(N-1) N N-1 N 1 2 ans.append(now) ans.append ans append now uf = UnionFind(N) uf UnionFind(N) UnionFind N for i in reversed(range(M)):

    if i == 0: break 
    a,b = AB[i]
    a,b = a-1, b-1

    if not uf.is_same(a,b):
        #print(now, uf.get_size(a) , uf.get_size(b), uf.size)
        now -= uf.get_size(a) * uf.get_size(b)
        #print("---", now)
        uf.unite(a,b)
        #uf.root(a)
        #uf.root(b)

    ans.append(now) i reversed(range(M)) reversed range(M) range M if i == 0: break 
     i == 0 i 0 a,b = AB[i] a AB[i] AB i b a,b = a-1, b-1 a a-1 a 1 b b-1 b 1 if not uf.is_same(a,b):
        #print(now, uf.get_size(a) , uf.get_size(b), uf.size)
        now -= uf.get_size(a) * uf.get_size(b)
        #print("---", now)
        uf.unite(a,b)
        #uf.root(a)
        #uf.root(b)

     not uf.is_same(a,b) uf.is_same(a,b) uf.is_same uf is_same a b now -= uf.get_size(a) * uf.get_size(b) now uf.get_size(a) * uf.get_size(b) uf.get_size(a) uf.get_size uf get_size a uf.get_size(b) uf.get_size uf get_size b uf.unite(a,b) uf.unite uf unite a b ans.append(now) ans.append ans append now for i in reversed(range(len(ans))):
    print(ans[i]) i reversed(range(len(ans))) reversed range(len(ans)) range len(ans) len ans print(ans[i]) print ans[i] ans i uf = UnionFind(N) UnionFind(N) uf class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * N
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
    def get_size(self, a):
        return self.size[self.root(a)] class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * N
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
    def get_size(self, a):
        return self.size[self.root(a)] UnionFind now = N*(N-1) // 2 N*(N-1) // 2 now M = map(int, input().split()) map(int, input().split()) M b = AB[i] AB[i] b now -= uf.get_size(a) * uf.get_size(b) uf.get_size(a) * uf.get_size(b) now a,b = a-1, b-1 a-1 a N,M = map(int, input().split()) map(int, input().split()) N a,b = AB[i] AB[i] a ans = [] [] ans AB = [tuple(map(int, input().split())) for _ in range(M)] [tuple(map(int, input().split())) for _ in range(M)] AB b = a-1, b-1 b-1 b

class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * N
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
    def get_size(self, a):
        return self.size[self.root(a)]

N,M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]

ans = []


now = N*(N-1) // 2
ans.append(now)

uf = UnionFind(N)
for i in reversed(range(M)):

    if i == 0: break 
    a,b = AB[i]
    a,b = a-1, b-1

    if not uf.is_same(a,b):
        #print(now, uf.get_size(a) , uf.get_size(b), uf.size)
        now -= uf.get_size(a) * uf.get_size(b)
        #print("---", now)
        uf.unite(a,b)
        #uf.root(a)
        #uf.root(b)

    ans.append(now)

for i in reversed(range(len(ans))):
    print(ans[i])