N, M = gets.split(' ').map(&:to_i)

@par = (0..N).to_a

def root(i)
	if @par[i] == i
		return i
	end
	@par[i] = root(@par[i])
end

def same(i, j)
	root(i) == root(j)
end

@size = [1] * (N + 1)
def size(i)
	@size[i] = @size[root(i)]
end

@rank = [1] * (N + 1)
def unite(i, j)
	i = root(i)
	j = root(j)
	if i != j
		if @rank[i] > @rank[j]
			@par[j] = i
			@size[i] += @size[j]
		else
			@par[i] = j
			@size[j] += @size[i]
			if @rank[i] == @rank[j]
				@rank[j] += 1
			end
		end
	end
end

bridge = []
M.times do
	x, y = gets.split(' ').map(&:to_i)
	bridge.unshift([x, y])
end

cnt = N * (N - 1) / 2
inconv = []
bridge.each do |a, b|
	inconv.unshift(cnt)
	if !same(a, b)
		cnt -= size(a) * size(b)
		unite(a, b)
	end
end

puts inconv