object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt
  val a = Array.fill(m, 2)(sc.nextInt - 1).reverse

  val trees = Array.fill(n)(new UnionFind)

  val ans = a.scanLeft((n * (n - 1) / 2)){
    (i, j) =>
      if (trees(j(0)).isSameUnion(trees(j(1)))) {
        trees(j(0)).merge(trees(j(1)))
        i
      }
      else {
        val unc = i - trees(j(0)).size * trees(j(1)).size
        trees(j(0)).merge(trees(j(1)))
        unc
      }
  }.reverse.tail

  ans.foreach(println)

  class UnionFind{
    /*
    要素ごとに UnionFind object を生成して扱う
     */
    private var mParent: UnionFind = this
    private var mSize: Int = 1
    private def parent: UnionFind = {
      if (mParent != this){
        mParent = mParent.parent
      }
      mParent
    }
    def isSameUnion(that: UnionFind): Boolean = {
      parent == that.parent
    }
    def size: Int = parent.mSize
    def merge(that: UnionFind): Unit = {
      if (!isSameUnion(that)){
        val thisP = parent
        val thatP = that.parent
        if (thisP.mSize < thatP.mSize){
          thisP.mParent = thatP
          thatP.mSize += thisP.mSize
        }else {
          thatP.mParent = thisP
          thisP.mSize += thatP.mSize
        }
      }
    }
  }
}
