# -*- coding: utf-8 -*-

"""

Created on Thu Sep 12 10:38:04 2019

D - Decayed Bridges

実行時間制限: 2 sec / メモリ制限: 1024 MB



配点 : 

400

 点

@author: justwah

"""



import sys

read = sys.stdin.readline



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

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



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



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

rank = [0]*(n+1)

size = [1]*(n+1)



def root(x): #recursively find root for a node

    if parent[x] == x: # if at root, return self

        return x

    else:

        parent[x] = root(parent[x])  # while searching rejoint queried node to a common parent for hierarchical tree

        return parent[x]

    

def merge(a, b):

    a = root(a)

    b = root(b)

    if rank[a] < rank[b]: # joint lower rank node to a higher rank one

        parent[a] = b

    else:

        parent[b] = a

        if rank[a] == rank[b]: # rank only change if two same rank node joined

            rank[a] +=1

    size[a] += size[b]

    size[b] = size[a]

    return



ans = [score]

for a, b in l:

    a = root(a)

    b = root(b)

    if a != b:

        score -= size[a] * size[b]    

        merge(a, b)

        ans.append(score)

    else:

        ans.append(score)



print((*reversed(ans[:-1])))

# -*- coding: utf-8 -*-

"""

Created on Thu Sep 12 10:38:04 2019

D - Decayed Bridges

実行時間制限: 2 sec / メモリ制限: 1024 MB



配点 : 

400

 点

@author: justwah

"""



import sys

read = sys.stdin.readline



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

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



l = reversed([list(tuple(map(int, read().split()))) for i in range(m)])



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

rank = [0]*(n+1)

size = [1]*(n+1)



def root(x): #recursively find root for a node

    if parent[x] == x: # if at root, return self

        return x

    else:

        parent[x] = root(parent[x])  # while searching rejoint queried node to a common parent for hierarchical tree

        return parent[x]

    

def merge(a, b):

    a = root(a)

    b = root(b)

    if rank[a] < rank[b]: # joint lower rank node to a higher rank one

        parent[a] = b

    else:

        parent[b] = a

        if rank[a] == rank[b]: # rank only change if two same rank node joined

            rank[a] +=1

    size[a] += size[b]

    size[b] = size[a]

    return



ans = [score]

for a, b in l:

    a = root(a)

    b = root(b)

    if a != b:

        score -= size[a] * size[b]    

        merge(a, b)

        ans.append(score)

    else:

        ans.append(score)



print((*reversed(ans[:-1])))

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 10:38:04 2019
D - Decayed Bridges
実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 
400
 点
@author: justwah
"""
import sys

read = sys.stdin.readline
n, m = list(map(int, read().split()))
score = n * (n - 1) // 2
l = reversed([list(tuple(map(int, input().split()))) for i in range(m)])
parent = [i for i in range(n + 1)]
rank = [0] * (n + 1)
size = [1] * (n + 1)


def root(x):  # recursively find root for a node
    if parent[x] == x:  # if at root, return self
        return x
    else:
        parent[x] = root(
            parent[x]
        )  # while searching rejoint queried node to a common parent for hierarchical tree
        return parent[x]


def merge(a, b):
    a = root(a)
    b = root(b)
    if rank[a] < rank[b]:  # joint lower rank node to a higher rank one
        parent[a] = b
    else:
        parent[b] = a
        if rank[a] == rank[b]:  # rank only change if two same rank node joined
            rank[a] += 1
    size[a] += size[b]
    size[b] = size[a]
    return


ans = [score]
for a, b in l:
    a = root(a)
    b = root(b)
    if a != b:
        score -= size[a] * size[b]
        merge(a, b)
        ans.append(score)
    else:
        ans.append(score)
print((*reversed(ans[:-1])))

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 10:38:04 2019
D - Decayed Bridges
実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 
400
 点
@author: justwah
"""
import sys

read = sys.stdin.readline
n, m = list(map(int, input().split()))
score = n * (n - 1) // 2
l = reversed([list(tuple(map(int, read().split()))) for i in range(m)])
parent = [i for i in range(n + 1)]
rank = [0] * (n + 1)
size = [1] * (n + 1)


def root(x):  # recursively find root for a node
    if parent[x] == x:  # if at root, return self
        return x
    else:
        parent[x] = root(
            parent[x]
        )  # while searching rejoint queried node to a common parent for hierarchical tree
        return parent[x]


def merge(a, b):
    a = root(a)
    b = root(b)
    if rank[a] < rank[b]:  # joint lower rank node to a higher rank one
        parent[a] = b
    else:
        parent[b] = a
        if rank[a] == rank[b]:  # rank only change if two same rank node joined
            rank[a] += 1
    size[a] += size[b]
    size[b] = size[a]
    return


ans = [score]
for a, b in l:
    a = root(a)
    b = root(b)
    if a != b:
        score -= size[a] * size[b]
        merge(a, b)
        ans.append(score)
    else:
        ans.append(score)
print((*reversed(ans[:-1])))

-n, m = list(map(int, read().split())) +n, m = list(map(int, input().split())) -l = reversed([list(tuple(map(int, input().split()))) for i in range(m)]) +l = reversed([list(tuple(map(int, read().split()))) for i in range(m)])