class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
    @count = Array.new(size, 1)
  end

  def find_parent(x)
    @parent[x] == x ? x : @parent[x] = find_parent(@parent[x])
  end

  def unite(x, y)
    x_parent = find_parent(x)
    y_parent = find_parent(y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
      @count[x_parent] += @count[y_parent]
    else
      @parent[x_parent] = y_parent
      @count[y_parent] += @count[x_parent]
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def same?(x, y)
    find_parent(x) == find_parent(y)
  end

  def count(x)
    @count[find_parent(x)]
  end

  def inspect
    "rank:#{@rank.inspect}\nparent:#{@parent.inspect}\ncount:#{@count.inspect}\n"
  end
end

def decayed_bridges(n, edges)
  uf = UnionFind.new(n)
  comb = [n * (n - 1) / 2]

  edges.reverse_each do |x, y|
    prev = comb[-1]
    if uf.same?(x, y)
      comb << prev
    else
      comb << prev - uf.count(x) * uf.count(y)
    end

    uf.unite(x, y)
  end

  comb.pop
  comb.reverse_each {|c| puts c }
end

n, m = gets.split.map(&:to_i)
edges = []
m.times do
  x, y = gets.split.map(&:to_i)
  edges << [x - 1, y - 1]
end

decayed_bridges(n, edges)