import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val edges = Array.tabulate(m){_ ⇒
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    (a, b)
  }
  val nodes = Array.tabulate(n){_ ⇒ new UnionFind}
  var current = n.toLong * (n - 1) / 2
  var history = Nil
  for ((a, b) ← edges.reverse){
    history ::= current
    if (!nodes(a).isSameUnion(nodes(b))) {
      current -= nodes(a).size * nodes(b).size
      nodes(a).merge(nodes(b))
    }
  }
  println(
    history.mkString("\n")
  )

  class UnionFind{
    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
        }
      }
    }
  }
}