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)

  val tree = UnionFindTree(n)
  val ans = a.reverse.map{ i =>
    tree.union(i(0), i(1))
    tree.getNodes
  }.map{ i =>
    val a = for {
      (v1, i1) <- i.zipWithIndex
      (v2, i2) <- i.zipWithIndex
      if (i1 < i2)
    } yield {
      v1 * v2
    }
    a.sum
  }.reverse.tail :+ (n * (n - 1)) / 2

  ans.foreach(println)

  case class UnionFindTree(size: Int) {
    import scala.collection.mutable.ArrayBuffer

    val par = Array.fill(size)(-1)

    def getNodes = {
      List.fill(par.count(_ == -1))(1) :::
      par.filter(_ != -1).map(i => find(i)._1).groupBy(identity).map {
        case (k, v) => v.size
      }.toList
    }

    def find(x: Int, rank: Int = 0): (Int, Int) = {
      par(x) match {
        case -1 => par(x) = x; (x, rank)
        case p if x == p => (p, rank)
        case p => {
          val (newRoot, newRank) = find(p, rank + 1)
          par(x) = newRoot
          (newRoot, newRank)
        }
      }
    }

    def union(x: Int, y: Int): Unit = {
      val (xRoot, xRank) = find(x)
      val (yRoot, yRank) = find(y)
      val newRoot = if (xRank > yRank) yRoot else xRoot
      if (xRoot != yRoot) {
        par(xRoot) = newRoot
        par(yRoot) = newRoot
      }
      par(x) = newRoot
      par(y) = newRoot
    }

    def check(x: Int, y:Int) = {
      val (xRoot, xRank) = find(x)
      val (yRoot, yRank) = find(y)
      xRoot == yRoot
    }
  }
}
