import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def calc(a: Seq[Long]): Long = {
    var r = a.length
    var sum = 0
    for (i <- a.indices) {
      r -= a(i)
      sum += a(i) * r
    }
    sum
  }

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val AB = Array.fill(M)(sc.nextInt - 1, sc.nextInt - 1)

    val as = Range(0, N).toBuffer // (0,1,2,...)
    val ns = ArrayBuffer.fill(N)(1L) // (1,1,1,...)

    AB.reverse.map { case (a, b) =>
      val ans = calc(ns)
      val ai = as(a)
      val bi = as(b)
      for (i <- as.indices) {
        if (as(i) == bi) as(i) = ai
      }
      ns(ai) += ns(bi)
      ns(bi) = 0
      ans
    }.reverse.mkString("\n")
  }
}
