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)


def comb(n):
    return (n * (n - 1)) // 2


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

results = []
fuben = comb(n)
results.append(fuben)

uf = UnionFind(n)

for i in range(m)[::-1]:
    a, b = ABs[i]
    a -= 1
    b -= 1
    if uf.same(a, b):
        results.append(fuben)
    else:
        tmp = comb(uf.size(a)) + comb(uf.size(b))
        uf.union(a, b)
        fuben = fuben + tmp - comb(uf.size(a))
        results.append(fuben)

for result in results[-2::-1]:
    print(result) 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 def comb(n):
    return (n * (n - 1)) // 2 comb return (n * (n - 1)) // 2 (n * (n - 1)) // 2 n * (n - 1) n n - 1 n 1 2 n n n, m = list(map(int, input().split())) n list(map(int, input().split())) list 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 ABs = [list(map(int, input().split())) for _ in range(m)] ABs [list(map(int, input().split())) for _ in range(m)] results = [] results [] fuben = comb(n) fuben comb(n) comb n results.append(fuben) results.append results append fuben uf = UnionFind(n) uf UnionFind(n) UnionFind n for i in range(m)[::-1]:
    a, b = ABs[i]
    a -= 1
    b -= 1
    if uf.same(a, b):
        results.append(fuben)
    else:
        tmp = comb(uf.size(a)) + comb(uf.size(b))
        uf.union(a, b)
        fuben = fuben + tmp - comb(uf.size(a))
        results.append(fuben) i range(m)[::-1] (m) range m ::-1 -1 a, b = ABs[i] a ABs[i] ABs i b a -= 1 a 1 b -= 1 b 1 if uf.same(a, b):
        results.append(fuben)
    else:
        tmp = comb(uf.size(a)) + comb(uf.size(b))
        uf.union(a, b)
        fuben = fuben + tmp - comb(uf.size(a))
        results.append(fuben) uf.same(a, b) uf.same uf same a b results.append(fuben) results.append results append fuben tmp = comb(uf.size(a)) + comb(uf.size(b)) tmp comb(uf.size(a)) + comb(uf.size(b)) comb(uf.size(a)) comb uf.size(a) uf.size uf size a comb(uf.size(b)) comb uf.size(b) uf.size uf size b uf.union(a, b) uf.union uf union a b fuben = fuben + tmp - comb(uf.size(a)) fuben fuben + tmp - comb(uf.size(a)) fuben + tmp fuben tmp comb(uf.size(a)) comb uf.size(a) uf.size uf size a results.append(fuben) results.append results append fuben for result in results[-2::-1]:
    print(result) result results[-2::-1] results -2::-1 -2 -1 print(result) print result n, m = list(map(int, input().split())) list(map(int, input().split())) n a -= 1 1 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) 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 comb(n):
    return (n * (n - 1)) // 2 def comb(n):
    return (n * (n - 1)) // 2 comb tmp = comb(uf.size(a)) + comb(uf.size(b)) comb(uf.size(a)) + comb(uf.size(b)) tmp fuben = fuben + tmp - comb(uf.size(a)) fuben + tmp - comb(uf.size(a)) fuben ABs = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] ABs fuben = comb(n) comb(n) fuben b = ABs[i] ABs[i] b m = list(map(int, input().split())) list(map(int, input().split())) m a, b = ABs[i] ABs[i] a b -= 1 1 b results = [] [] results uf = UnionFind(n) UnionFind(n) uf
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)


def comb(n):
    return (n * (n - 1)) // 2


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

results = []
fuben = comb(n)
results.append(fuben)

uf = UnionFind(n)

for i in range(m)[::-1]:
    a, b = ABs[i]
    a -= 1
    b -= 1
    if uf.same(a, b):
        results.append(fuben)
    else:
        tmp = comb(uf.size(a)) + comb(uf.size(b))
        uf.union(a, b)
        fuben = fuben + tmp - comb(uf.size(a))
        results.append(fuben)

for result in results[-2::-1]:
    print(result)
