#!/usr/bin/env python3
import sys

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        

def main():
    N, M = map(int, input().split())
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    ans = [0] * M
    ans[-1] = N * (N-1) // 2
    # 逆順に橋が出来ると不便さが変わるか調べる
    uf = UnionFind(N)
    for i in range(M-1):
        # aとbが連結か調べる
        a, b = A[M-1-i]-1, B[M-1-i]-1
        if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

    [print(a) for a in ans]
    

if __name__ == '__main__':
    main() import sys sys class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
         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 find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

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

     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
         union 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.parents[x] > self.parents[y]:
            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 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 self self x x y y def main():
    N, M = map(int, input().split())
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    ans = [0] * M
    ans[-1] = N * (N-1) // 2
    # 逆順に橋が出来ると不便さが変わるか調べる
    uf = UnionFind(N)
    for i in range(M-1):
        # aとbが連結か調べる
        a, b = A[M-1-i]-1, B[M-1-i]-1
        if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

    [print(a) for a in ans]
     main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = [None] * M A [None] * M [None] None M B = [None] * M B [None] * M [None] None M for i in range(M):
        A[i], B[i] = map(int, input().split())

     i range(M) range M A[i], B[i] = map(int, input().split()) A[i] A i map(int, input().split()) map int input().split() ().split () input split B[i] B i ans = [0] * M ans [0] * M [0] 0 M ans[-1] = N * (N-1) // 2 ans[-1] ans -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):
        # aとbが連結か調べる
        a, b = A[M-1-i]-1, B[M-1-i]-1
        if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

     i range(M-1) range M-1 M 1 a, b = A[M-1-i]-1, B[M-1-i]-1 a A[M-1-i]-1 A[M-1-i] A M-1-i M-1 M 1 i 1 b B[M-1-i]-1 B[M-1-i] B M-1-i M-1 M 1 i 1 if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

     uf.find(a) == uf.find(b) uf.find(a) uf.find uf find a uf.find(b) uf.find uf find b ans[M-i-2] = ans[M-i-1] ans[M-i-2] ans M-i-2 M-i M i 2 ans[M-i-1] ans M-i-1 M-i M i 1 ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)]) ans[M-i-2] ans M-i-2 M-i M i 2 ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)]) ans[M-i-1] ans M-i-1 M-i M i 1 abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)]) abs(uf.parents[uf.find(a)]) abs uf.parents[uf.find(a)] uf.parents uf parents uf.find(a) uf.find uf find a abs(uf.parents[uf.find(b)]) abs uf.parents[uf.find(b)] uf.parents uf parents uf.find(b) uf.find uf find b uf.union(a, b) uf.union uf union a b print(a) for a in ans for a in ans a ans for a in ans print(a) print a [print(a) for a in ans] if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, M = map(int, input().split())
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    ans = [0] * M
    ans[-1] = N * (N-1) // 2
    # 逆順に橋が出来ると不便さが変わるか調べる
    uf = UnionFind(N)
    for i in range(M-1):
        # aとbが連結か調べる
        a, b = A[M-1-i]-1, B[M-1-i]-1
        if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

    [print(a) for a in ans]
     def main():
    N, M = map(int, input().split())
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    ans = [0] * M
    ans[-1] = N * (N-1) // 2
    # 逆順に橋が出来ると不便さが変わるか調べる
    uf = UnionFind(N)
    for i in range(M-1):
        # aとbが連結か調べる
        a, b = A[M-1-i]-1, B[M-1-i]-1
        if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

    [print(a) for a in ans]
     main class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
         class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
         UnionFind
#!/usr/bin/env python3
import sys

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        

def main():
    N, M = map(int, input().split())
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    ans = [0] * M
    ans[-1] = N * (N-1) // 2
    # 逆順に橋が出来ると不便さが変わるか調べる
    uf = UnionFind(N)
    for i in range(M-1):
        # aとbが連結か調べる
        a, b = A[M-1-i]-1, B[M-1-i]-1
        if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

    [print(a) for a in ans]
    

if __name__ == '__main__':
    main()
