import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val A = Array(M) {0}
    val B = Array(M) {0}

    for (i in A.indices) {
        val (a, b) = readLine()!!.split(" ").map{it.toInt()}
        A[i] = a - 1
        B[i] = b - 1
    }

    val uf = UnionFind(N)
    val res = ArrayList<Long>()
    res.add(N * (N - 1L) / 2)

    for (i in A.indices.reversed()) {
        if (uf.same(A[i], B[i])) {
            res.add(res.last())
        } else {
            res.add(res.last() - uf.getCardinalityOf(A[i]) * uf.getCardinalityOf(B[i]))
            uf.unite(A[i], B[i])
        }
    }

    res.removeAt(res.size - 1)
    res.reverse()
    for (v in res) {
        println(v)
    }
}

private class UnionFind(n: Int) {
    val size = n

    private val parent: Array<Int>
    private val cardinality: Array<Long>

    init {
        parent = Array(size) { -1 }
        cardinality = Array(size) { 1L }
    }

    /**
     * Find a root element of a set `x` belongs to.
     */
    fun find(x: Int): Int {
        return if (parent[x] == -1) {
            x
        } else {
            parent[x] = find(parent[x])
            parent[x]
        }
    }

    /**
     * Unite sets contain two elements `x` and `y`.
     * If `x` and `y` already belong to a same set, nothing happens.
     *
     * @return If `x` and `y` belong to a same set, return false.
     */
    fun unite(x: Int, y: Int): Boolean {
        val u = find(x)
        val v = find(y)
        if (u == v) {
            return false
        }

        val newSize = cardinality[v] + cardinality[u]

        if (cardinality[u] < cardinality[v]) {
            parent[u] = v
            cardinality[v] = newSize
        } else {
            parent[v] = u
            cardinality[u] = newSize
        }

        return true
    }

    /**
     * Check whether `x` and `y` belongs to a same set.
     *
     * @return `true` if `x` and `y` are in a same set.
     */
    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    /**
     * Get a size of a set `x` belongs to.
     */
    fun getCardinalityOf(x: Int): Long {
        return cardinality[find(x)]
    }
}
