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



n, m = list(map(int, input().split()))

A = [list(map(int, input().split())) for i in range(m)]



for i in range(m):

    for j in range(2):

        A[i][j] -= 1



U = UnionFind(n)

ans = n * (n-1) // 2

ANS = []

for i in range(m-1, -1, -1):

    ANS.append(ans)

    a = A[i][0]

    b = A[i][1]

    ua = U.find(a)

    ub = U.find(b)

    if ua != ub:

        ans -= U.parents[ua] * U.parents[ub]

        U.union(ua, ub)



for i in range(len(ANS)-1, -1, -1):

    print((ANS[i]))
import sys

input = sys.stdin.readline



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 size(self, x):

        if self.parents[x] < 0:

            return -self.parents[x]

        else:

            self.parents[x] = self.size(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



n, m = list(map(int, input().split()))

A = [list(map(int, input().split())) for i in range(m)]



for i in range(m):

    for j in range(2):

        A[i][j] -= 1



U = UnionFind(n)

ans = n * (n-1) // 2

ANS = []

for i in range(m-1, -1, -1):

    ANS.append(ans)

    a = A[i][0]

    b = A[i][1]

    ua = U.find(a)

    ub = U.find(b)

    if ua != ub:

        ans -= U.size(ua) * U.size(ub)

        U.union(ua, ub)



for i in range(len(ANS)-1, -1, -1):

    print((ANS[i]))
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


n, m = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
    for j in range(2):
        A[i][j] -= 1
U = UnionFind(n)
ans = n * (n - 1) // 2
ANS = []
for i in range(m - 1, -1, -1):
    ANS.append(ans)
    a = A[i][0]
    b = A[i][1]
    ua = U.find(a)
    ub = U.find(b)
    if ua != ub:
        ans -= U.parents[ua] * U.parents[ub]
        U.union(ua, ub)
for i in range(len(ANS) - 1, -1, -1):
    print((ANS[i]))

import sys

input = sys.stdin.readline


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 size(self, x):
        if self.parents[x] < 0:
            return -self.parents[x]
        else:
            self.parents[x] = self.size(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


n, m = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
    for j in range(2):
        A[i][j] -= 1
U = UnionFind(n)
ans = n * (n - 1) // 2
ANS = []
for i in range(m - 1, -1, -1):
    ANS.append(ans)
    a = A[i][0]
    b = A[i][1]
    ua = U.find(a)
    ub = U.find(b)
    if ua != ub:
        ans -= U.size(ua) * U.size(ub)
        U.union(ua, ub)
for i in range(len(ANS) - 1, -1, -1):
    print((ANS[i]))

+import sys + +input = sys.stdin.readline + + +            return self.parents[x] + +    def size(self, x): +        if self.parents[x] < 0: +            return -self.parents[x] +        else: +            self.parents[x] = self.size(self.parents[x]) -        ans -= U.parents[ua] * U.parents[ub] +        ans -= U.size(ua) * U.size(ub)