class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)][::-1]

u = UnionFind(n)
ans = [n*(n-1)//2]
for a, b in ab:
    a, b = a-1, b-1
    ra, rb = u.root(a), u.root(b)
    p = u.parents[ra] * u.parents[rb] if ra != rb else 0
    ans.append(ans[-1] - p)
    u.unite(a, b)
ans.pop()
for i in ans[::-1]:
    print(i) class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return UnionFind def __init__(self, n):
        self.parents = [-1]*n
    
     __init__ self.parents = [-1]*n self.parents self parents [-1]*n [-1] -1 n self self n n def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
     root if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x return self.root(self.parents[x]) self.root(self.parents[x]) self.root self root self.parents[x] self.parents self parents x self self x x def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return unite x = self.root(x) x self.root(x) self.root self root x y = self.root(y) y self.root(y) self.root self root y if x == y:
            return
         x == y x y return if x > y:
            x, y = y, x
         x > y x y x, y = y, x x y y x self.parents[x] += self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y self.parents[y] = x self.parents[y] self.parents self parents y x return self self x x y y n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ab = [list(map(int, input().split())) for _ in range(m)][::-1] ab [list(map(int, input().split())) for _ in range(m)][::-1] [list(map(int, input().split())) for _ in range(m)] ::-1 -1 u = UnionFind(n) u UnionFind(n) UnionFind n 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 ab:
    a, b = a-1, b-1
    ra, rb = u.root(a), u.root(b)
    p = u.parents[ra] * u.parents[rb] if ra != rb else 0
    ans.append(ans[-1] - p)
    u.unite(a, b) a b ab a, b = a-1, b-1 a a-1 a 1 b b-1 b 1 ra, rb = u.root(a), u.root(b) ra u.root(a) u.root u root a rb u.root(b) u.root u root b p = u.parents[ra] * u.parents[rb] if ra != rb else 0 p u.parents[ra] * u.parents[rb] if ra != rb else 0 ra != rb ra rb u.parents[ra] * u.parents[rb] u.parents[ra] u.parents u parents ra u.parents[rb] u.parents u parents rb 0 ans.append(ans[-1] - p) ans.append ans append ans[-1] - p ans[-1] ans -1 p u.unite(a, b) u.unite u unite a b ans.pop() ans.pop ans pop for i in ans[::-1]:
    print(i) i ans[::-1] ans ::-1 -1 print(i) print i m = map(int, input().split()) map(int, input().split()) m ab = [list(map(int, input().split())) for _ in range(m)][::-1] [list(map(int, input().split())) for _ in range(m)][::-1] ab p = u.parents[ra] * u.parents[rb] if ra != rb else 0 u.parents[ra] * u.parents[rb] if ra != rb else 0 p n, m = map(int, input().split()) map(int, input().split()) n u = UnionFind(n) UnionFind(n) u ans = [n*(n-1)//2] [n*(n-1)//2] ans rb = u.root(a), u.root(b) u.root(b) rb class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return UnionFind b = a-1, b-1 b-1 b a, b = a-1, b-1 a-1 a ra, rb = u.root(a), u.root(b) u.root(a) ra
class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)][::-1]

u = UnionFind(n)
ans = [n*(n-1)//2]
for a, b in ab:
    a, b = a-1, b-1
    ra, rb = u.root(a), u.root(b)
    p = u.parents[ra] * u.parents[rb] if ra != rb else 0
    ans.append(ans[-1] - p)
    u.unite(a, b)
ans.pop()
for i in ans[::-1]:
    print(i)