import sys

sys.setrecursionlimit(100003)

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

bridges=[list(map(int,input().split())) for i in range(m)][::-1]

inconv=[n*(n-1)//2]*m

class UnionFind(object):

    def __init__(self, N):

        self.parent = [i for i in range(N)]

        self.size = [1 for i in range(N)]

 

    def merge(self, a, b):

        if self.issame(a,b):

            return

        pa = self.root(a)

        pb = self.root(b)

        self.parent[pa] = pb

        self.size[pb] += self.size[pa]

    

    def root(self, x):

        p = self.parent[x]

        if p == x:

            return x

        else:

            r = self.root(p)

            self.parent[x] = r

            return r

        

    def issame(self, x, y):

        return self.root(x) == self.root(y)

    

    def getsize(self, x):

        return self.size[self.root(x)]

uf = UnionFind(n)

for i in range(m-1):

    if uf.issame(bridges[i][0]-1,bridges[i][1]-1):

        inconv[i+1]=inconv[i]

        continue

    inconv[i+1]=inconv[i]-uf.getsize(bridges[i][0]-1)*uf.getsize(bridges[i][1]-1)

    uf.merge(bridges[i][0]-1,bridges[i][1]-1)

for i in range(m):

    print((inconv[m-i-1]))
import sys

sys.setrecursionlimit(1000003)

input=sys.stdin.readline

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

bridges=[list(map(int,input().split())) for i in range(m)][::-1]

inconv=[n*(n-1)//2]*m

class UnionFind(object):

    def __init__(self, N):

        self.parent = [i for i in range(N)]

        self.size = [1 for i in range(N)]

 

    def merge(self, a, b):

        if self.issame(a,b):

            return

        pa = self.root(a)

        pb = self.root(b)

        self.parent[pa] = pb

        self.size[pb] += self.size[pa]

    

    def root(self, x):

        p = self.parent[x]

        if p == x:

            return x

        else:

            r = self.root(p)

            self.parent[x] = r

            return r

        

    def issame(self, x, y):

        return self.root(x) == self.root(y)

    

    def getsize(self, x):

        return self.size[self.root(x)]

uf = UnionFind(n)

for i in range(m-1):

    if uf.issame(bridges[i][0]-1,bridges[i][1]-1):

        inconv[i+1]=inconv[i]

        continue

    inconv[i+1]=inconv[i]-uf.getsize(bridges[i][0]-1)*uf.getsize(bridges[i][1]-1)

    uf.merge(bridges[i][0]-1,bridges[i][1]-1)

for i in range(m):

    print((inconv[m-i-1]))

import sys

sys.setrecursionlimit(100003)
n, m = list(map(int, input().split()))
bridges = [list(map(int, input().split())) for i in range(m)][::-1]
inconv = [n * (n - 1) // 2] * m


class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]

    def merge(self, a, b):
        if self.issame(a, b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]

    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r

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

    def getsize(self, x):
        return self.size[self.root(x)]


uf = UnionFind(n)
for i in range(m - 1):
    if uf.issame(bridges[i][0] - 1, bridges[i][1] - 1):
        inconv[i + 1] = inconv[i]
        continue
    inconv[i + 1] = inconv[i] - uf.getsize(bridges[i][0] - 1) * uf.getsize(
        bridges[i][1] - 1
    )
    uf.merge(bridges[i][0] - 1, bridges[i][1] - 1)
for i in range(m):
    print((inconv[m - i - 1]))

import sys

sys.setrecursionlimit(1000003)
input = sys.stdin.readline
n, m = list(map(int, input().split()))
bridges = [list(map(int, input().split())) for i in range(m)][::-1]
inconv = [n * (n - 1) // 2] * m


class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]

    def merge(self, a, b):
        if self.issame(a, b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]

    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r

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

    def getsize(self, x):
        return self.size[self.root(x)]


uf = UnionFind(n)
for i in range(m - 1):
    if uf.issame(bridges[i][0] - 1, bridges[i][1] - 1):
        inconv[i + 1] = inconv[i]
        continue
    inconv[i + 1] = inconv[i] - uf.getsize(bridges[i][0] - 1) * uf.getsize(
        bridges[i][1] - 1
    )
    uf.merge(bridges[i][0] - 1, bridges[i][1] - 1)
for i in range(m):
    print((inconv[m - i - 1]))

-sys.setrecursionlimit(100003) +sys.setrecursionlimit(1000003) +input = sys.stdin.readline