class UnionFind(val n: Int) {

    private var par: IntArray
    private var sz: IntArray
    private var rank: IntArray

    init {
        par = IntArray(n, { it })
        sz = IntArray(n, { 1 })
        rank = IntArray(n, { 0 })
    }

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

    fun unite(x: Int, y: Int) {
        val xp = find(x)
        val yp = find(y)
        if(xp == yp) return
        if(rank[xp] < rank[yp]) {
            par[xp] = yp
            sz[yp] += sz[xp]
        }
        else {
            par[yp] = xp
            sz[xp] += sz[yp]
            if(rank[xp] == rank[yp])rank[xp]++
        }
    }

    fun same(x: Int, y: Int) = find(x) == find(y)
    fun size(a: Int) = sz[find(a)]
}

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map{ it.toInt() }
    val v = Array(m, {Pair(0, 0)})

    for(i in 0 until m){
        var (a, b) = readLine()!!.split(" " ).map{ it.toInt() }
        a--
        b--
        v[i] = Pair(a, b)
    }


    val uf = UnionFind(n)
    val ans = LongArray(m)
    var now = 0L
    for(i in m - 1 downTo 0) {
        val (a, b) = v[i]
        ans[i] = now
        if(!uf.same(a, b)){
            now += uf.size(a).toLong() * uf.size(b).toLong()
            uf.unite(a, b)
        }
    }

    for(i in 0 until m){
        println(n.toLong() * (n.toLong() - 1L) / 2 - ans[i])
    }
}