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



bridges = []

for i in range(m):

    bridges.append([int(x) for x in input().split()])

'''

g = list(range(n+1))

ng = [1 for _ in range(n+1)]

gl = [[i] for i in range(n+1)]

ans = []

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

ans.append(unconf)





for x in reversed(bridges):

    a,b = x

    if g[a] != g[b]:

        tmp = ng[g[a]] * ng[g[b]]

        ng[g[a]] = ng[g[a]]+ng[g[b]]

        gl[g[a]] = gl[g[a]] + gl[g[b]]

        for y in gl[g[b]]:

            g[y] = g[a]

        unconf -= tmp

        ans.append(unconf)

    else:

        ans.append(unconf)





ans.reverse()

ans.pop(0)

for x in ans:

    print(x)

'''

def root(par, ifpar, a):

    while ifpar[a] != 1:

       a = par[a]

    return a 



def unite(cnt, par, ifpar, npar, depth, ra, rb):

    if depth[ra] >= depth[rb]:

        npar[ra] = npar[ra] + npar[rb]

        par[rb] = ra

        ifpar[rb] = 0

        if depth[ra] == depth[rb]:

            depth[ra] += 1

    else:

        npar[rb] = npar[rb] + npar[ra]

        par[ra] = rb

        ifpar[ra] = 0



par = list(range(n+1))

ifpar = [1 for _ in range(n+1)]

npar = [1 for _ in range(n+1)]

depth = [1 for _ in range(n+1)]



ans = []

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

ans.append(unconf)

cnt = 0



for x in reversed(bridges):

    a,b = x

    ra = root(par, ifpar, a)

    rb = root(par, ifpar, b)

    if ra != rb:

        tmp = npar[ra] * npar[rb]

        unite(cnt, par, ifpar, npar, depth, ra, rb)

        unconf -= tmp

    ans.append(unconf)

    cnt += 1



ans.reverse()

ans.pop(0)

for x in ans:

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



bridges = []

for i in range(m):

    bridges.append([int(x) for x in input().split()])



def root(par, a):

    while par[a] != -1:

       a = par[a]

    return a 



def unite(par, npar, depth, ra, rb):

    if depth[ra] >= depth[rb]:

        npar[ra] = npar[ra] + npar[rb]

        par[rb] = ra

        if depth[ra] == depth[rb]:

            depth[ra] += 1

    else:

        npar[rb] = npar[rb] + npar[ra]

        par[ra] = rb



par = [-1 for _ in range(n+1)]

npar = [1 for _ in range(n+1)]

depth = [1 for _ in range(n+1)]



ans = []

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

ans.append(unconf)



for x in reversed(bridges):

    a,b = x

    ra = root(par, a)

    rb = root(par, b)

    if ra != rb:

        tmp = npar[ra] * npar[rb]

        unite(par, npar, depth, ra, rb)

        unconf -= tmp

    ans.append(unconf)



ans.reverse()

ans.pop(0)

for x in ans:

    print(x)
n, m = list(map(int, input().split()))
bridges = []
for i in range(m):
    bridges.append([int(x) for x in input().split()])
"""
g = list(range(n+1))
ng = [1 for _ in range(n+1)]
gl = [[i] for i in range(n+1)]
ans = []
unconf = n*(n-1)//2
ans.append(unconf)
for x in reversed(bridges):
    a,b = x
    if g[a] != g[b]:
        tmp = ng[g[a]] * ng[g[b]]
        ng[g[a]] = ng[g[a]]+ng[g[b]]
        gl[g[a]] = gl[g[a]] + gl[g[b]]
        for y in gl[g[b]]:
            g[y] = g[a]
        unconf -= tmp
        ans.append(unconf)
    else:
        ans.append(unconf)
ans.reverse()
ans.pop(0)
for x in ans:
    print(x)
"""


def root(par, ifpar, a):
    while ifpar[a] != 1:
        a = par[a]
    return a


def unite(cnt, par, ifpar, npar, depth, ra, rb):
    if depth[ra] >= depth[rb]:
        npar[ra] = npar[ra] + npar[rb]
        par[rb] = ra
        ifpar[rb] = 0
        if depth[ra] == depth[rb]:
            depth[ra] += 1
    else:
        npar[rb] = npar[rb] + npar[ra]
        par[ra] = rb
        ifpar[ra] = 0


par = list(range(n + 1))
ifpar = [1 for _ in range(n + 1)]
npar = [1 for _ in range(n + 1)]
depth = [1 for _ in range(n + 1)]
ans = []
unconf = n * (n - 1) // 2
ans.append(unconf)
cnt = 0
for x in reversed(bridges):
    a, b = x
    ra = root(par, ifpar, a)
    rb = root(par, ifpar, b)
    if ra != rb:
        tmp = npar[ra] * npar[rb]
        unite(cnt, par, ifpar, npar, depth, ra, rb)
        unconf -= tmp
    ans.append(unconf)
    cnt += 1
ans.reverse()
ans.pop(0)
for x in ans:
    print(x)

n, m = list(map(int, input().split()))
bridges = []
for i in range(m):
    bridges.append([int(x) for x in input().split()])


def root(par, a):
    while par[a] != -1:
        a = par[a]
    return a


def unite(par, npar, depth, ra, rb):
    if depth[ra] >= depth[rb]:
        npar[ra] = npar[ra] + npar[rb]
        par[rb] = ra
        if depth[ra] == depth[rb]:
            depth[ra] += 1
    else:
        npar[rb] = npar[rb] + npar[ra]
        par[ra] = rb


par = [-1 for _ in range(n + 1)]
npar = [1 for _ in range(n + 1)]
depth = [1 for _ in range(n + 1)]
ans = []
unconf = n * (n - 1) // 2
ans.append(unconf)
for x in reversed(bridges):
    a, b = x
    ra = root(par, a)
    rb = root(par, b)
    if ra != rb:
        tmp = npar[ra] * npar[rb]
        unite(par, npar, depth, ra, rb)
        unconf -= tmp
    ans.append(unconf)
ans.reverse()
ans.pop(0)
for x in ans:
    print(x)

-""" -g = list(range(n+1)) -ng = [1 for _ in range(n+1)] -gl = [[i] for i in range(n+1)] -ans = [] -unconf = n*(n-1)//2 -ans.append(unconf) -for x in reversed(bridges): -    a,b = x -    if g[a] != g[b]: -        tmp = ng[g[a]] * ng[g[b]] -        ng[g[a]] = ng[g[a]]+ng[g[b]] -        gl[g[a]] = gl[g[a]] + gl[g[b]] -        for y in gl[g[b]]: -            g[y] = g[a] -        unconf -= tmp -        ans.append(unconf) -    else: -        ans.append(unconf) -ans.reverse() -ans.pop(0) -for x in ans: -    print(x) -""" -def root(par, ifpar, a): -    while ifpar[a] != 1: +def root(par, a): +    while par[a] != -1: -def unite(cnt, par, ifpar, npar, depth, ra, rb): +def unite(par, npar, depth, ra, rb): -        ifpar[rb] = 0 -        ifpar[ra] = 0 -par = list(range(n + 1)) -ifpar = [1 for _ in range(n + 1)] +par = [-1 for _ in range(n + 1)] -cnt = 0 -    ra = root(par, ifpar, a) -    rb = root(par, ifpar, b) +    ra = root(par, a) +    rb = root(par, b) -        unite(cnt, par, ifpar, npar, depth, ra, rb) +        unite(par, npar, depth, ra, rb) -    cnt += 1