fun main(args: Array<String>) {
    val (n, m) = run {
        val (n, m) = readLine()!!.split(' ')
        Pair(n.toLong(), m.toInt())
    }

    val bridges = (0 until m).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        Pair(a, b)
    }.reversed()

    val unionFind = UnionFind(n.toInt())

    val res = LongArray(m) { 0L }
    res[0] = n * (n - 1) / 2

    bridges.take(m - 1).forEachIndexed { i, bridge ->
        val x = bridge.first - 1
        val y = bridge.second - 1

        if (unionFind.same(x, y)) {
            res[i + 1] = res[i]
            return@forEachIndexed
        }

        res[i + 1] = res[i] - unionFind.size(x).toLong() * unionFind.size(y).toLong()

        unionFind.unite(x, y)
    }

    res.reversed().forEach {
        println(it)
    }
}

private class UnionFind(n: Int) {

    private val par = IntArray(n) { -1 }

    fun find(x: Int): Int {
        if (par[x] < 0) {
            return x
        }
        par[x] = find(par[x])
        return par[x]
    }

    fun unite(x: Int, y: Int) {
        val x1 = find(x)
        val y1 = find(y)
        if (x1 == y1) return

        val (x2, y2) = if (par[x1] > par[y1]) {
            Pair(y1, x1)
        } else {
            Pair(x1, y1)
        }

        par[x2] += par[y2]
        par[y2] = x2
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun size(x: Int): Int {
        return -par[find(x)]
    }

}
