class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            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
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False


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

ans = [0] * m
ans[m-1] = n * (n-1) // 2
UF = UnionFind(n)
for i in range(m-1, 0, -1):
    a, b = ab[i]
    if UF.same(a-1, b-1):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)]
        UF.unite(a-1, b-1)

for a in ans:
    print(a) class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            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
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False UnionFind def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        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.par = [i for i in range(n)] self.par self par [i for i in range(n)] self.rank = [0] * n self.rank self rank [0] * n [0] 0 n self.size = [1] * n self.size self size [1] * n [1] 1 n self self n n def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     find if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(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.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
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
     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
        
         x == y x y return if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            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.par[x] = y self.par[x] self.par self par x y self.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x 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 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 self x x y y def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False same if self.find(x) == self.find(y):
            return True
        else:
            return False self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y return True True return False False 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)] ab [list(map(int, input().split())) for _ in range(m)] ans = [0] * m ans [0] * m [0] 0 m 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 UF = UnionFind(n) UF UnionFind(n) UnionFind n for i in range(m-1, 0, -1):
    a, b = ab[i]
    if UF.same(a-1, b-1):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)]
        UF.unite(a-1, b-1) 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-1, b-1):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)]
        UF.unite(a-1, b-1) UF.same(a-1, b-1) UF.same UF same a-1 a 1 b-1 b 1 ans[i-1] = ans[i] ans[i-1] ans i-1 i 1 ans[i] ans i ans[i-1] = ans[i] - UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)] ans[i-1] ans i-1 i 1 ans[i] - UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)] ans[i] ans i UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)] UF.size[UF.find(a-1)] UF.size UF size UF.find(a-1) UF.find UF find a-1 a 1 UF.size[UF.find(b-1)] UF.size UF size UF.find(b-1) UF.find UF find b-1 b 1 UF.unite(a-1, b-1) UF.unite UF unite a-1 a 1 b-1 b 1 for a in ans:
    print(a) a ans print(a) print a n, m = map(int, input().split()) map(int, input().split()) n UF = UnionFind(n) UnionFind(n) UF ans = [0] * m [0] * m ans class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            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
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            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
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False UnionFind a, b = ab[i] ab[i] a m = map(int, input().split()) map(int, input().split()) m ab = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] ab b = ab[i] ab[i] b
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            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
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False


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

ans = [0] * m
ans[m-1] = n * (n-1) // 2
UF = UnionFind(n)
for i in range(m-1, 0, -1):
    a, b = ab[i]
    if UF.same(a-1, b-1):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)]
        UF.unite(a-1, b-1)

for a in ans:
    print(a)
