class UnionFind(object):
    def __init__(self, n):
        self.par = [-1] * n
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots())

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

# 最後は全部つながってない
# うしろから順番につなぐ
edges = []
for _ in range(M):
    ai, bi = map(int, input().split())
    ai, bi = ai - 1, bi - 1
    edges.append((ai, bi))
edges.reverse()

ans = [N * (N - 1) // 2]
for (ai, bi) in edges:
    if not uf.same(ai, bi):
        ans.append(ans[-1] - uf.size(ai) * uf.size(bi))
    else:
        ans.append(ans[-1])
    uf.unite(ai, bi)

for a in ans[::-1][1:]:
    print(a) class UnionFind(object):
    def __init__(self, n):
        self.par = [-1] * n
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots()) UnionFind def __init__(self, n):
        self.par = [-1] * n
    
     __init__ self.par = [-1] * n self.par self par [-1] * n [-1] -1 n self self n n def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     find if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     self.par[x] < 0 self.par[x] self.par self par x 0 return x x self.par[x] = self.find(self.par[x]) self.par[x] self.par self par x self.find(self.par[x]) self.find self find self.par[x] self.par self par x return self.par[x] self.par[x] self.par self par x self self x x def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

     unite x = self.find(x) x self.find(x) self.find self find x y = self.find(y) y self.find(y) self.find self find y if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

     x == y x y return False False if self.par[x] > self.par[y]:
                x, y = y, x
             self.par[x] > self.par[y] self.par[x] self.par self par x self.par[y] self.par self par y x, y = y, x x y y x self.par[x] += self.par[y] self.par[x] self.par self par x self.par[y] self.par self par y self.par[y] = x self.par[y] self.par self par y x return True True self self x x y y def same(self, x, y):
        return self.find(x) == self.find(y)

     same return self.find(x) == self.find(y) self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y self self x x y y def size(self, x):
        return -self.par[self.find(x)]

     size return -self.par[self.find(x)] -self.par[self.find(x)] self.par[self.find(x)] self.par self par self.find(x) self.find self find x self self x x def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

     members root = self.find(x) root self.find(x) self.find self find x i for i in range(self.n) if self.find(i) == root for i in range(self.n) if self.find(i) == root i range(self.n) range self.n self n self.find(i) == root self.find(i) self.find self find i root if self.find(i) == root i return [i for i in range(self.n) if self.find(i) == root] [i for i in range(self.n) if self.find(i) == root] self self x x def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

     roots i for i, x in enumerate(self.par) if x < 0 for i, x in enumerate(self.par) if x < 0 i x enumerate(self.par) enumerate self.par self par x < 0 x 0 if x < 0 i return [i for i, x in enumerate(self.par) if x < 0] [i for i, x in enumerate(self.par) if x < 0] self self def group_count(self):
        return len(self.roots()) group_count return len(self.roots()) len(self.roots()) len self.roots() self.roots self roots self self object N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M uf = UnionFind(N) uf UnionFind(N) UnionFind N edges = [] edges [] for _ in range(M):
    ai, bi = map(int, input().split())
    ai, bi = ai - 1, bi - 1
    edges.append((ai, bi)) _ range(M) range M ai, bi = map(int, input().split()) ai map(int, input().split()) map int input().split() ().split () input split bi ai, bi = ai - 1, bi - 1 ai ai - 1 ai 1 bi bi - 1 bi 1 edges.append((ai, bi)) edges.append edges append (ai, bi) ai bi edges.reverse() edges.reverse edges reverse ans = [N * (N - 1) // 2] ans [N * (N - 1) // 2] N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 for (ai, bi) in edges:
    if not uf.same(ai, bi):
        ans.append(ans[-1] - uf.size(ai) * uf.size(bi))
    else:
        ans.append(ans[-1])
    uf.unite(ai, bi) (ai, bi) ai bi edges if not uf.same(ai, bi):
        ans.append(ans[-1] - uf.size(ai) * uf.size(bi))
    else:
        ans.append(ans[-1])
     not uf.same(ai, bi) uf.same(ai, bi) uf.same uf same ai bi ans.append(ans[-1] - uf.size(ai) * uf.size(bi)) ans.append ans append ans[-1] - uf.size(ai) * uf.size(bi) ans[-1] ans -1 uf.size(ai) * uf.size(bi) uf.size(ai) uf.size uf size ai uf.size(bi) uf.size uf size bi ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 uf.unite(ai, bi) uf.unite uf unite ai bi for a in ans[::-1][1:]:
    print(a) a ans[::-1][1:] [::-1] ans ::-1 -1 1: 1 print(a) print a uf = UnionFind(N) UnionFind(N) uf ai, bi = map(int, input().split()) map(int, input().split()) ai edges = [] [] edges bi = map(int, input().split()) map(int, input().split()) bi ai, bi = ai - 1, bi - 1 ai - 1 ai N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M ans = [N * (N - 1) // 2] [N * (N - 1) // 2] ans bi = ai - 1, bi - 1 bi - 1 bi class UnionFind(object):
    def __init__(self, n):
        self.par = [-1] * n
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots()) class UnionFind(object):
    def __init__(self, n):
        self.par = [-1] * n
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots()) UnionFind
class UnionFind(object):
    def __init__(self, n):
        self.par = [-1] * n
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots())

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

# 最後は全部つながってない
# うしろから順番につなぐ
edges = []
for _ in range(M):
    ai, bi = map(int, input().split())
    ai, bi = ai - 1, bi - 1
    edges.append((ai, bi))
edges.reverse()

ans = [N * (N - 1) // 2]
for (ai, bi) in edges:
    if not uf.same(ai, bi):
        ans.append(ans[-1] - uf.size(ai) * uf.size(bi))
    else:
        ans.append(ans[-1])
    uf.unite(ai, bi)

for a in ans[::-1][1:]:
    print(a)