class UnionFind():
    def __init__(self, n):
        self.n = 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 size(self, x):
        return -self.parents[self.find(x)]

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

N, M = map(int,input().split())
UFT = UnionFind(N)
bridges = []
for _ in range(M):
    A, B = map(int,input().split())
    bridges.append((A-1, B-1))
bridges.reverse()

ans = [N * (N-1) // 2]
for i in range(M-1):
    temp = ans[-1]
    A, B = bridges[i]
    if not UFT.same(A, B):
        temp -= UFT.size(A) * UFT.size(B)
        UFT.union(A, B)
    ans.append(temp)

ans.reverse()
for a in ans:
    print(a) class UnionFind():
    def __init__(self, n):
        self.n = 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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

     __init__ self.n = n self.n self n n 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 size(self, x):
        return -self.parents[self.find(x)]

     size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x def same(self, x, y):
        return self.find(x) == self.find(y) same return self.find(x) == self.find(y) self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find 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 UFT = UnionFind(N) UFT UnionFind(N) UnionFind N bridges = [] bridges [] for _ in range(M):
    A, B = map(int,input().split())
    bridges.append((A-1, B-1)) _ range(M) range M A, B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B bridges.append((A-1, B-1)) bridges.append bridges append (A-1, B-1) A-1 A 1 B-1 B 1 bridges.reverse() bridges.reverse bridges reverse ans = [N * (N-1) // 2] ans [N * (N-1) // 2] N * (N-1) // 2 N * (N-1) N N-1 N 1 2 for i in range(M-1):
    temp = ans[-1]
    A, B = bridges[i]
    if not UFT.same(A, B):
        temp -= UFT.size(A) * UFT.size(B)
        UFT.union(A, B)
    ans.append(temp) i range(M-1) range M-1 M 1 temp = ans[-1] temp ans[-1] ans -1 A, B = bridges[i] A bridges[i] bridges i B if not UFT.same(A, B):
        temp -= UFT.size(A) * UFT.size(B)
        UFT.union(A, B)
     not UFT.same(A, B) UFT.same(A, B) UFT.same UFT same A B temp -= UFT.size(A) * UFT.size(B) temp UFT.size(A) * UFT.size(B) UFT.size(A) UFT.size UFT size A UFT.size(B) UFT.size UFT size B UFT.union(A, B) UFT.union UFT union A B ans.append(temp) ans.append ans append temp ans.reverse() ans.reverse ans reverse for a in ans:
    print(a) a ans print(a) print a bridges = [] [] bridges N, M = map(int,input().split()) map(int,input().split()) N class UnionFind():
    def __init__(self, n):
        self.n = 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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind():
    def __init__(self, n):
        self.n = 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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind M = map(int,input().split()) map(int,input().split()) M A, B = map(int,input().split()) map(int,input().split()) A B = map(int,input().split()) map(int,input().split()) B temp = ans[-1] ans[-1] temp UFT = UnionFind(N) UnionFind(N) UFT ans = [N * (N-1) // 2] [N * (N-1) // 2] ans temp -= UFT.size(A) * UFT.size(B) UFT.size(A) * UFT.size(B) temp B = bridges[i] bridges[i] B A, B = bridges[i] bridges[i] A
class UnionFind():
    def __init__(self, n):
        self.n = 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 size(self, x):
        return -self.parents[self.find(x)]

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

N, M = map(int,input().split())
UFT = UnionFind(N)
bridges = []
for _ in range(M):
    A, B = map(int,input().split())
    bridges.append((A-1, B-1))
bridges.reverse()

ans = [N * (N-1) // 2]
for i in range(M-1):
    temp = ans[-1]
    A, B = bridges[i]
    if not UFT.same(A, B):
        temp -= UFT.size(A) * UFT.size(B)
        UFT.union(A, B)
    ans.append(temp)

ans.reverse()
for a in ans:
    print(a)