import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val ans = mu.ListBuffer.empty[Long]
  (n.toLong * (n-1) / 2L) +=: ans
  val uft = new UnionFindTree(n)

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt - 1))
    .toArray
    .reverse
    .init
    .foreach { e => {
      val a = e(0)
      val b = e(1)
      if(uft.root(a) != uft.root(b)) {
        (ans.head - uft.size(a).toLong * uft.size(b).toLong) +=: ans
        // println(uft.size(a) + " " + uft.size(b))
        uft.unite(a, b)
      }
      else ans.head +=: ans
    }}

  println(ans.mkString("\n"))

  class UnionFindTree(n:Int) {
    val par  = Array.range(0, n)
    val rank = Array.fill(n)(1)
    val _size = Array.fill(n)(1)

    def root(x:Int):Int = {
      if(par(x) == x) x
      else { par(x) = root(par(x)); par(x) }
    }

    def size(x:Int):Int = {
      _size(root(x))
    }

    def same(x:Int, y:Int):Boolean = root(x) == root(y)

    def unite(x:Int, y:Int):Unit = {
      val rx = root(x)
      val ry = root(y)
      if(rx == ry) return

      if(rank(rx) < rank(ry)) {
        par(rx) = ry
        _size(ry) += _size(rx)
      }
      else {
        par(ry) = rx
        _size(rx) += _size(ry)
        if(rank(rx) == rank(ry)) rank(rx) += 1
      }
    }
  }
}