N, M = list(map(int, input().split()))

lis = [[x, -1] for x in range(1, N + 1)]

Blis = [list(map(int, input().split())) for _ in range(M)]

inc = int(N*(N - 1)/2)

ans = [x for x in range(M)]

ans[M - 1] = inc

def root(a):

    if lis[a - 1][1] < 0:

        return lis[a - 1][0]

    else:

        k = root(lis[a - 1][1])

        lis[a - 1][1] = k

        return k

def size(a):

    return -lis[root(a) - 1][1]

def connect(a, b):

    A = root(a)

    B = root(b)

    if A == B:

        return None

    else:

        if size(A) < size(B):

            A, B = B, A

        lis[A - 1][1] += lis[B - 1][1]

        lis[B - 1][1] = A

for i in reversed(list(range(1, M))):

    if root(Blis[i][0]) != root(Blis[i][1]):

        ans[i - 1] = ans[i] - size(Blis[i][0])*size(Blis[i][1])

        connect(Blis[i][0], Blis[i][1])

    else:

      ans[i - 1] = ans[i]    

for i in range(M):

  print((ans[i]))
N, M = list(map(int, input().split()))

Parent = [-1 for x in range(N + 5)]

lis = [list(map(int, input().split())) for _ in range(M)]

ini = int(N*(N - 1)/2)

ans = [x for x in range(M)]

ans[M - 1] = ini

def root(a):

    if Parent[a] < 0:

        return a

    else:

        k = root(Parent[a])

        Parent[a] = k

        return k

def size(a):

    return -Parent[root(a)]

def connect(a, b):

    A = root(a)

    B = root(b)

    if A == B:

        return None

    else:

        if size(A) < size(B):

            A, B = B, A

        Parent[A] += Parent[B]

        Parent[B] = A

for i in reversed(list(range(1, M))):

    ans[i - 1] = ans[i]

    if root(lis[i][0]) != root(lis[i][1]):

        ans[i - 1] -= size(lis[i][0])*size(lis[i][1])

        connect(lis[i][0], lis[i][1])    

for i in range(M):

  print((ans[i]))
N, M = list(map(int, input().split()))
lis = [[x, -1] for x in range(1, N + 1)]
Blis = [list(map(int, input().split())) for _ in range(M)]
inc = int(N * (N - 1) / 2)
ans = [x for x in range(M)]
ans[M - 1] = inc


def root(a):
    if lis[a - 1][1] < 0:
        return lis[a - 1][0]
    else:
        k = root(lis[a - 1][1])
        lis[a - 1][1] = k
        return k


def size(a):
    return -lis[root(a) - 1][1]


def connect(a, b):
    A = root(a)
    B = root(b)
    if A == B:
        return None
    else:
        if size(A) < size(B):
            A, B = B, A
        lis[A - 1][1] += lis[B - 1][1]
        lis[B - 1][1] = A


for i in reversed(list(range(1, M))):
    if root(Blis[i][0]) != root(Blis[i][1]):
        ans[i - 1] = ans[i] - size(Blis[i][0]) * size(Blis[i][1])
        connect(Blis[i][0], Blis[i][1])
    else:
        ans[i - 1] = ans[i]
for i in range(M):
    print((ans[i]))

N, M = list(map(int, input().split()))
Parent = [-1 for x in range(N + 5)]
lis = [list(map(int, input().split())) for _ in range(M)]
ini = int(N * (N - 1) / 2)
ans = [x for x in range(M)]
ans[M - 1] = ini


def root(a):
    if Parent[a] < 0:
        return a
    else:
        k = root(Parent[a])
        Parent[a] = k
        return k


def size(a):
    return -Parent[root(a)]


def connect(a, b):
    A = root(a)
    B = root(b)
    if A == B:
        return None
    else:
        if size(A) < size(B):
            A, B = B, A
        Parent[A] += Parent[B]
        Parent[B] = A


for i in reversed(list(range(1, M))):
    ans[i - 1] = ans[i]
    if root(lis[i][0]) != root(lis[i][1]):
        ans[i - 1] -= size(lis[i][0]) * size(lis[i][1])
        connect(lis[i][0], lis[i][1])
for i in range(M):
    print((ans[i]))

-lis = [[x, -1] for x in range(1, N + 1)] -Blis = [list(map(int, input().split())) for _ in range(M)] -inc = int(N * (N - 1) / 2) +Parent = [-1 for x in range(N + 5)] +lis = [list(map(int, input().split())) for _ in range(M)] +ini = int(N * (N - 1) / 2) -ans[M - 1] = inc +ans[M - 1] = ini -    if lis[a - 1][1] < 0: -        return lis[a - 1][0] +    if Parent[a] < 0: +        return a -        k = root(lis[a - 1][1]) -        lis[a - 1][1] = k +        k = root(Parent[a]) +        Parent[a] = k -    return -lis[root(a) - 1][1] +    return -Parent[root(a)] -        lis[A - 1][1] += lis[B - 1][1] -        lis[B - 1][1] = A +        Parent[A] += Parent[B] +        Parent[B] = A -    if root(Blis[i][0]) != root(Blis[i][1]): -        ans[i - 1] = ans[i] - size(Blis[i][0]) * size(Blis[i][1]) -        connect(Blis[i][0], Blis[i][1]) -    else: -        ans[i - 1] = ans[i] +    ans[i - 1] = ans[i] +    if root(lis[i][0]) != root(lis[i][1]): +        ans[i - 1] -= size(lis[i][0]) * size(lis[i][1]) +        connect(lis[i][0], lis[i][1])