object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, M = sc.nextInt
    val A = new Array[Int](M)
    val B = new Array[Int](M)
    for (i <- 0 until M) {
      A(i) = sc.nextInt - 1
      B(i) = sc.nextInt - 1
    }

    val uf = new UnionFind(N)
    val result = new Array[Int](M + 1)
    result(M) += N * (N - 1) / 2
    for (i <- M - 1 to 0 by -1) {
      if (uf.same(A(i), B(i))) {
        result(i) = result(i + 1)
      } else {
        result(i) = result(i + 1) - uf.size(A(i)) * uf.size(B(i))
      }
      uf.unite(A(i), B(i))
    }

    for (i <- 1 to M) {
      println(result(i))
    }
  }

  class UnionFind(n: Int) {
    val par = new Array[Int](n)
    private val siz: Array[Int] = Array.fill[Int](n)(1)

    for (i <- 0 until n) {
      par(i) = i
    }

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

    def unite(x: Int, y: Int): Unit = {
      val rootX = root(x)
      val rootY = root(y)
      if (rootX == rootY) return
      if (siz(x) < siz(y)) {
        par(rootX) = rootY
        siz(y) += siz(x)
      } else {
        par(rootY) = rootX
        siz(x) += siz(y)
      }
    }

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

    def groupCount: Int = {
      (0 until n).count(x => x == par(x))
    }

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

}