### BUGGY CODE ###

#!/usr/bin/env python3
import sys

# refered to
# rank : http://at274.hatenablog.com/entry/2018/02/02/173000
# size : abc120 kaisetsu
class UnionFind:
    def __init__(self, n):
        # par = Parent Number or NoV
        self.par = [-1] * (n+1)
        # rank = Tree Height
        self.rank = [0] * (n+1)
    
    # Returns the number of sets to which x belongs
    def size(self, x):
        return -1*self.par[self.find(x)]
    
    def size_list(self):
        return [x*(-1) for x in self.par[1:] if x < 0]

    # Returns number if root
    def find(self, x):
        if(self.par[x] < 1):
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    # Are the parents of x and y the same?
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        # find root 
        x = self.find(x)
        y = self.find(y)

        # Already x connect to y
        if(x == y):
            return False

        # Reconnect
        if(self.size(x) < self.size(y)):
            x,y = y,x
        
        # update x size
        self.par[x] += self.par[y]
        # set parent number of y to x
        self.par[y] = x

        return True 
    
    def root_nodes(self):
        return [-i for i in self.par[1:] if i <= -1]
    
    

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    import math
    def combination(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    ans = []

    uf = UnionFind(N)
    ans.append((N-1)*N//2)
    for i in range(M-1, 0, -1):
        uf.union(A[i], B[i])
        r = uf.root_nodes()
        tans = sum([x*(N-x) for x in r])//2
        ans.append(tans)
    
    for i in reversed(range(len(ans))):
        print(ans[i])

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# from ../../myProgConLib/unionfind import UnionFind

class UnionFind:
    def __init__(self, n):
        # par = Parent Number or NoV
        self.par = [-1] * (n+1)
        # rank = Tree Height
        self.rank = [0] * (n+1)
    
    # 自分が所属する集合の数を返す
    def size(self, x):
        return -1*self.par[self.find(x)]

    # 根なら番号を返す
    def find(self, x):
        
        if(self.par[x] < 1):
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    # 親が同じか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # もう繋がれている
        if(x == y):
            return False

        # つなぎ替える
        if(self.size(x) < self.size(y)):
            x,y = y,x
        
        # xのサイズを更新
        self.par[x] += self.par[y]
        # yのサイズ(おやばんごう)をxに
        self.par[y] = x

        return True 
 

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    uf = UnionFind(N)
    ans = [0] * M 
    ans[M-1] = int(N*(N-1)/2)

    for i in reversed(range(1, M)):
        # A[i] -= 1
        # B[i] -= 1

        ans[i-1] = ans[i]

        if(uf.find(A[i]) != uf.find(B[i])):
            # print('SoP', uf.size(A[i]), uf.size(B[i]))
            ans[i-1] -= uf.size(A[i]) * uf.size(B[i])
            uf.union(A[i], B[i])
        # print(i, uf.par)

    for i in ans:
        print(i)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()