class UnionFind
  def initialize(n)
    @n = n
    @par = Array.new(@n).map.with_index{|x, i| i}
    @chl = Array.new(@n).map{[]}
    @con = (@n-1)*(@n-2)/2
  end
  def union(a, b)
    pa, pb = [@par[a], @par[b]]
    if pa < pb then
      absorb(a, b)
    elsif pa > pb then
      absorb(b, a)
    end
  end
  def con
    @con
  end
  
  private
  
  def absorb(pa, ch)
    par = @par[pa]
    chl = @par[ch]
    @con += (@chl[par].size * (@chl[par].size+1))/2
    @con += (@chl[chl].size * (@chl[chl].size+1))/2
    @chl[chl].each{|c|
      @chl[par] << c
      @par[c] = par
    }
    @chl[chl] = nil
    @chl[par] << chl
    @par[chl] = par
    @con -= (@chl[par].size * (@chl[par].size+1))/2
  end
end

N, M = gets.chomp.split(" ").map(&:to_i)
E = Array.new(M).map{
  gets.chomp.split(" ").map(&:to_i)
}

uf = UnionFind.new(N+1)
ans = E.reverse.map{|a, b|
  uf.union(a, b)
  uf.con
}

ans.unshift(N*(N-1)/2)
ans.pop
puts ans.reverse*?\n
