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, *X = list(map(int,open(0).read().split()))



uf = UnionFind(N + 1)



S = N * (N - 1) // 2

r = [S]



while X:

  b, a = X.pop(), X.pop()

  if not uf.same(a, b):

    S -= uf.size(a) * uf.size(b)

  r.append(S)

  uf.union(a, b)



for a in r[-2::-1]:

  print(a)
def find(x):

  if P[x] < 0:

    return x

  else:

    P[x] = find(P[x])

    return P[x]



N, M, *X = list(map(int,open(0).read().split()))

P = [-1] * (N + 1)

S = N * (N - 1) // 2

r = [S]



while X:

  b, a = find(X.pop()), find(X.pop())

  if a != b:

    S -= P[a] * P[b]

    if P[a] > P[b]:

      a, b = b, a

    P[a] += P[b]

    P[b] = a

  r.append(S)



for a in r[-2::-1]:

  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)


N, M, *X = list(map(int, open(0).read().split()))
uf = UnionFind(N + 1)
S = N * (N - 1) // 2
r = [S]
while X:
    b, a = X.pop(), X.pop()
    if not uf.same(a, b):
        S -= uf.size(a) * uf.size(b)
    r.append(S)
    uf.union(a, b)
for a in r[-2::-1]:
    print(a)

def find(x):
    if P[x] < 0:
        return x
    else:
        P[x] = find(P[x])
        return P[x]


N, M, *X = list(map(int, open(0).read().split()))
P = [-1] * (N + 1)
S = N * (N - 1) // 2
r = [S]
while X:
    b, a = find(X.pop()), find(X.pop())
    if a != b:
        S -= P[a] * P[b]
        if P[a] > P[b]:
            a, b = b, a
        P[a] += P[b]
        P[b] = a
    r.append(S)
for a in r[-2::-1]:
    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) +def find(x): +    if P[x] < 0: +        return x +    else: +        P[x] = find(P[x]) +        return P[x] -uf = UnionFind(N + 1) +P = [-1] * (N + 1) -    b, a = X.pop(), X.pop() -    if not uf.same(a, b): -        S -= uf.size(a) * uf.size(b) +    b, a = find(X.pop()), find(X.pop()) +    if a != b: +        S -= P[a] * P[b] +        if P[a] > P[b]: +            a, b = b, a +        P[a] += P[b] +        P[b] = a -    uf.union(a, b)