ma = lambda : map(int,input().split())
import sys
sys.setrecursionlimit(10**6)
class unionfind():
    def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x!=y:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x]

n,m = ma()
ans = [0]*m
ab = []
for i in range(m):
    a,b = ma()
    ab.append((a-1,b-1))

uf = unionfind(n)
ans[m-1] = n*(n-1)//2
for i in range(m-1,0,-1):
    a,b = ab[i]
    if uf.same(a,b):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - uf.get_size(a)*uf.get_size(b)
        uf.unite(a,b)
for a in ans:print(a) ma = lambda : map(int,input().split()) ma lambda : map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 class unionfind():
    def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x!=y:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x] unionfind def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

     __init__ self.par = list(range(n)) self.par self par list(range(n)) list range(n) range n self.size = [1]*n self.size self size [1]*n [1] 1 n self.rank = [0]*n self.rank self rank [0]*n [0] 0 n self self n n def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

     root if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

     self.par[x] == x self.par[x] self.par self par x x return x x self.par[x] = self.root(self.par[x]) self.par[x] self.par self par x self.root(self.par[x]) self.root self root 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 same(self,x,y):
        return self.root(x) == self.root(y)

     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 def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x!=y:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
     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:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
     x!=y x y if self.rank[x] < self.rank[y]:
                 x,y = y,x
             self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y x,y = y,x x y y x if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
             self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.rank[x]+=1 self.rank[x] self.rank self rank x 1 self.par[y] = x self.par[y] self.par self par y x self.size[x] +=self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y self self x x y y def get_size(self,x):
        x = self.root(x)
        return self.size[x] get_size x = self.root(x) x self.root(x) self.root self root x return self.size[x] self.size[x] self.size self size x self self x x n,m = ma() n ma() ma m ans = [0]*m ans [0]*m [0] 0 m ab = [] ab [] for i in range(m):
    a,b = ma()
    ab.append((a-1,b-1)) i range(m) range m a,b = ma() a ma() ma b ab.append((a-1,b-1)) ab.append ab append (a-1,b-1) a-1 a 1 b-1 b 1 uf = unionfind(n) uf unionfind(n) unionfind n ans[m-1] = n*(n-1)//2 ans[m-1] ans m-1 m 1 n*(n-1)//2 n*(n-1) n n-1 n 1 2 for i in range(m-1,0,-1):
    a,b = ab[i]
    if uf.same(a,b):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - uf.get_size(a)*uf.get_size(b)
        uf.unite(a,b) i range(m-1,0,-1) range m-1 m 1 0 -1 a,b = ab[i] a ab[i] ab i b if uf.same(a,b):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - uf.get_size(a)*uf.get_size(b)
        uf.unite(a,b) uf.same(a,b) uf.same uf same a b ans[i-1] = ans[i] ans[i-1] ans i-1 i 1 ans[i] ans i ans[i-1] = ans[i] - uf.get_size(a)*uf.get_size(b) ans[i-1] ans i-1 i 1 ans[i] - uf.get_size(a)*uf.get_size(b) ans[i] ans i 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 for a in ans:print(a) a ans b = ab[i] ab[i] b ma = lambda : map(int,input().split()) lambda : map(int,input().split()) ma n,m = ma() ma() n a,b = ma() ma() a ab = [] [] ab a,b = ab[i] ab[i] a b = ma() ma() b uf = unionfind(n) unionfind(n) uf class unionfind():
    def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x!=y:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x] class unionfind():
    def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x!=y:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x] unionfind ans = [0]*m [0]*m ans m = ma() ma() m
ma = lambda : map(int,input().split())
import sys
sys.setrecursionlimit(10**6)
class unionfind():
    def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x!=y:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x]

n,m = ma()
ans = [0]*m
ab = []
for i in range(m):
    a,b = ma()
    ab.append((a-1,b-1))

uf = unionfind(n)
ans[m-1] = n*(n-1)//2
for i in range(m-1,0,-1):
    a,b = ab[i]
    if uf.same(a,b):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - uf.get_size(a)*uf.get_size(b)
        uf.unite(a,b)
for a in ans:print(a)
