class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = [1]*n  # 各連結成分の大きさ

    def root(self, x):
        if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
        return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

        return 0


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

N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
AB.reverse()

UF = UnionFind(N)

ans = [N*(N-1)//2]
for a, b in AB:
    a, b = a-1, b-1
    ans.append(ans[-1] - UF.unite(a,b))

ans.reverse()
for a in ans[1:]: 
    print(a)
    class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = [1]*n  # 各連結成分の大きさ

    def root(self, x):
        if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
        return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

        return 0


    
    def same(self, x,y):
        return (self.root(x) == self.root(y)) UnionFind def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = [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.p = [i for i in range(n)] self.p self p [i for i in range(n)] self.components = [1]*n self.components self components [1]*n [1] 1 n self self n n def root(self, x):
        if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
        return self.p[x]
    
     root if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
         self.p[x] != x self.p[x] self.p self p x x stack = [x] stack [x] x while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
             True top = stack[-1] top stack[-1] stack -1 if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
             self.p[top] == top self.p[top] self.p self p top top break stack.append(self.p[top]) stack.append stack append self.p[top] self.p self p top for v in stack:
                self.p[v] = top
         v stack self.p[v] = top self.p[v] self.p self p v top return self.p[x] self.p[x] self.p self p x self self x x def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

        return 0


    
     unite x, y = self.root(x), self.root(y) x self.root(x) self.root self root x y self.root(y) self.root self root y if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

         x != y x y self.p[x] = y self.p[x] self.p self p x y size_x , size_y = self.components[x], self.components[y] size_x self.components[x] self.components self components x size_y self.components[y] self.components self components y self.components[x] = size_x + size_y self.components[x] self.components self components x size_x + size_y size_x size_y self.components[y] = size_x + size_y self.components[y] self.components self components y size_x + size_y size_x size_y return size_x * size_y size_x * size_y size_x size_y return 0 0 self self x x y y 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 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)] AB.reverse() AB.reverse AB reverse UF = UnionFind(N) UF 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
    ans.append(ans[-1] - UF.unite(a,b)) a b AB a, b = a-1, b-1 a a-1 a 1 b b-1 b 1 ans.append(ans[-1] - UF.unite(a,b)) ans.append ans append ans[-1] - UF.unite(a,b) ans[-1] ans -1 UF.unite(a,b) UF.unite UF unite a b ans.reverse() ans.reverse ans reverse for a in ans[1:]: 
    print(a)
    a ans[1:] ans 1: 1 print(a) print a a, b = a-1, b-1 a-1 a UF = UnionFind(N) UnionFind(N) UF b = a-1, b-1 b-1 b AB = [list(map(int,input().split())) for _ in range(M)] [list(map(int,input().split())) for _ in range(M)] AB class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = [1]*n  # 各連結成分の大きさ

    def root(self, x):
        if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
        return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

        return 0


    
    def same(self, x,y):
        return (self.root(x) == self.root(y)) class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = [1]*n  # 各連結成分の大きさ

    def root(self, x):
        if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
        return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

        return 0


    
    def same(self, x,y):
        return (self.root(x) == self.root(y)) UnionFind M = map(int,input().split()) map(int,input().split()) M ans = [N*(N-1)//2] [N*(N-1)//2] ans N, M = map(int,input().split()) map(int,input().split()) N
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = [1]*n  # 各連結成分の大きさ

    def root(self, x):
        if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
        return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

        return 0


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

N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
AB.reverse()

UF = UnionFind(N)

ans = [N*(N-1)//2]
for a, b in AB:
    a, b = a-1, b-1
    ans.append(ans[-1] - UF.unite(a,b))

ans.reverse()
for a in ans[1:]: 
    print(a)
   