N, M = [int(x) for x in input().split()]

bridge = [[int(x) for x in input().split()] for x in range(M)]



par = [int(x) for x in range(N+1)]  # 所属グループ

gn = [1 for _ in range(N+1)]





def group(i):

    if par[i] == i:

        return i

    else:

        return group(par[i])





def group_num(i):               # order(NlogN)?

    counter = 0

    for j in range(N+1):

        if group(j) == i:

            counter += 1

    return counter





ans = [int(N*(N-1)/2)]



for i, b in enumerate(bridge[::-1]):  # O(M)

    g0 = group(b[0])

    g1 = group(b[1])

    # print(i)

    if g0 > g1:

        ans.append(int(ans[-1] - gn[g0]*gn[g1]))

        par[g0] = g1

        gn[g1] += gn[g0]

        gn[g0] = 0

        par[g0] = g1

    elif g0 < g1:

        ans.append(int(ans[-1] - gn[g0]*gn[g1]))

        par[g1] = g0

        gn[g0] += gn[g1]

        gn[g1] = 0

    else:

        ans.append(ans[-1])



# print(par)

# print([group(x) for x in par])

for x in ans[::-1][1:]:

    print(x)

N, M = [int(x) for x in input().split()]

bridge = [[int(x) for x in input().split()] for x in range(M)]



par = [int(x) for x in range(N+1)]  # 所属グループ

gn = [1 for _ in range(N+1)]        # 各グループサイズ





def group(i):

    if par[i] == i:

        return i

    else:

        par[i] = group(par[i])

        return par[i]





ans = [int(N*(N-1)/2)]



for i, b in enumerate(bridge[::-1]):  # O(M)

    g0 = group(b[0])

    g1 = group(b[1])

    if g0 > g1:

        ans.append(int(ans[-1] - gn[g0]*gn[g1]))

        par[g0] = g1

        gn[g1] += gn[g0]

        gn[g0] = 0

    elif g0 < g1:

        ans.append(int(ans[-1] - gn[g0]*gn[g1]))

        par[g1] = g0

        gn[g0] += gn[g1]

        gn[g1] = 0

    else:

        ans.append(ans[-1])



for x in ans[::-1][1:]:

    print(x)

N, M = [int(x) for x in input().split()]
bridge = [[int(x) for x in input().split()] for x in range(M)]
par = [int(x) for x in range(N + 1)]  # 所属グループ
gn = [1 for _ in range(N + 1)]


def group(i):
    if par[i] == i:
        return i
    else:
        return group(par[i])


def group_num(i):  # order(NlogN)?
    counter = 0
    for j in range(N + 1):
        if group(j) == i:
            counter += 1
    return counter


ans = [int(N * (N - 1) / 2)]
for i, b in enumerate(bridge[::-1]):  # O(M)
    g0 = group(b[0])
    g1 = group(b[1])
    # print(i)
    if g0 > g1:
        ans.append(int(ans[-1] - gn[g0] * gn[g1]))
        par[g0] = g1
        gn[g1] += gn[g0]
        gn[g0] = 0
        par[g0] = g1
    elif g0 < g1:
        ans.append(int(ans[-1] - gn[g0] * gn[g1]))
        par[g1] = g0
        gn[g0] += gn[g1]
        gn[g1] = 0
    else:
        ans.append(ans[-1])
# print(par)
# print([group(x) for x in par])
for x in ans[::-1][1:]:
    print(x)

N, M = [int(x) for x in input().split()]
bridge = [[int(x) for x in input().split()] for x in range(M)]
par = [int(x) for x in range(N + 1)]  # 所属グループ
gn = [1 for _ in range(N + 1)]  # 各グループサイズ


def group(i):
    if par[i] == i:
        return i
    else:
        par[i] = group(par[i])
        return par[i]


ans = [int(N * (N - 1) / 2)]
for i, b in enumerate(bridge[::-1]):  # O(M)
    g0 = group(b[0])
    g1 = group(b[1])
    if g0 > g1:
        ans.append(int(ans[-1] - gn[g0] * gn[g1]))
        par[g0] = g1
        gn[g1] += gn[g0]
        gn[g0] = 0
    elif g0 < g1:
        ans.append(int(ans[-1] - gn[g0] * gn[g1]))
        par[g1] = g0
        gn[g0] += gn[g1]
        gn[g1] = 0
    else:
        ans.append(ans[-1])
for x in ans[::-1][1:]:
    print(x)

-gn = [1 for _ in range(N + 1)] +gn = [1 for _ in range(N + 1)]  # 各グループサイズ -        return group(par[i]) - - -def group_num(i):  # order(NlogN)? -    counter = 0 -    for j in range(N + 1): -        if group(j) == i: -            counter += 1 -    return counter +        par[i] = group(par[i]) +        return par[i] -    # print(i) -        par[g0] = g1 -# print(par) -# print([group(x) for x in par])