### BUGGY CODE ###

from queue import Queue
def  disintegration_Bridge(index):
    ConectMatrix[index[0]][index[1]] = '0'
    ConectMatrix[index[1]][index[0]] = '0'

def is_island(index):
    # indexから直接たどり着ける島リスト
    temp = [[i for i in range(n + 1) if ConectMatrix[j][i] == '1'] for j in range(n + 1)]
    mydic = ['0' for i in range(n+1)]
    q = Queue()
    q.put(index[0])
    while not q.empty():
        v = q.get()
        for j in temp[v]:
            if type(j) == int:
                if mydic[j] == '0':
                    mydic[j] = '1'
                    q.put(j)
            else:
                for node in j:
                    if mydic[node] == '0':
                        mydic[node] = '1'
                        q.put(node)

    if mydic[index[1]] == '1':
        return False
    else:
        return True

def find_root(index, mylist, mydic):
    mydic[index] = '1'
    candidate = mylist[index]
    temp = [j for j in range(1, n+1) if ConectMatrix[index][j] == '1']
    temp.append(mylist).set()
    for t in temp:
        if mydic[t] == '0':
            return find_root(temp)
    return temp

n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
ConectMatrix = [['0' for i in range(n + 1)] for j in range(n + 1)]

for brige in a:
    ConectMatrix[brige[1]][brige[0]] = '1'
    ConectMatrix[brige[0]][brige[1]] = '1'

for i in a:
    # print("-----{}----".format(i))
    # 橋の崩落
    disintegration_Bridge(i)
    # 直接繋がっていない島がある島を検索
    not_connect = [(i, j) for i in range(1, n + 1) for j in range(1, n + 1) if ConectMatrix[i][j] == '0' and i != j]
    [not_connect.remove((i[1], i[0])) for i in not_connect]
    counter = 0
    # print(not_connect)
    # 直接繋がっていないが迂回すればいけるか検索
    for index in not_connect:
        # AとBの島が迂回して繋がっているか判定
        temp = [[i for i in range(n + 1) if ConectMatrix[j][i] == '1'] for j in range(n + 1)]
        # print(temp)
        if is_island(index):
            # print(index)
            counter = counter + 1        


    print(counter)

### FIXED CODE ###

class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True


n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
ans = [int(n * (n - 1) / 2) for i in range(m)]
uni = UnionFind(n)

for i in range(m):
    if i == 0:
        continue
    A = a[-i][0]
    B = a[-i][1]

    if uni.root(A) != uni.root(B):
        ans[i] = ans[i-1] - uni.size(A) * uni.size(B)
        uni.Connect(A, B)
    else:
        ans[i] = ans[i-1]


for i in range(1, m+1):
    print(ans[-i])