import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val ab = Array(m) { sc.nextInt() to sc.nextInt() }

    val group = IntArray(n + 1) { it }
    val rank = LongArray(n + 1)
    val count = LongArray(n + 1) { 1 }

    fun find(index: Int): Int {
        return if (group[index] == index) {
            index
        } else {
            group[index] = find(group[index])
            group[index]
        }
    }

    fun unite(x: Int, y: Int) {
        val nx = find(x)
        val ny = find(y)

        if (nx == ny) return

        if (rank[nx] < rank[ny]) {
            group[ny] = nx
        } else {
            group[nx] = ny
            if (rank[nx] == rank[ny]) rank[nx]++
        }
    }

    val ret = LongArray(m + 1)
    (0 until ab.size).reversed().forEach { index ->
        val x = ab[index].first
        val y = ab[index].second

        val gx = find(x)
        val gy = find(y)

        if (gx == gy) {
            ret[index] = ret[index + 1]
            return@forEach
        }

        unite(gx, gy)
        (count[gx] * count[gy]).let {
            ret[index] = ret[index + 1] + it
            count[find(gx)] = count[gx] + count[gy]
        }
    }

    ret.drop(1).forEachIndexed { index, v ->
        println(ret.first() - ret[index + 1])
    }


}