class UnionFind(n:Int){
    val n = n
    var dat = Array(n, {i -> -1})
    fun unionSet(x:Int, y:Int):Boolean{
        var rx = root(x)  
        var ry = root(y)  
        if(rx != ry){
            if(dat[ry] < dat[rx]) {
                val tmp = rx
                rx = ry
                ry = tmp 
            }
            dat[rx] += dat[ry]
            dat[ry] = rx
        }
        return rx != ry
    }
    fun findSet(x:Int, y:Int):Boolean{
        return root(x) == root(y)
    }
    fun root(x:Int):Int{
        if(dat[x] >= 0) {
            dat[x] = root(dat[x])
            return dat[x]
        }
        return x
    }
    fun size(x:Int):Int{
        return -dat[root(x)]
    }
}


fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    var uf = UnionFind(n)
    var a = Array(m, {0}) 
    var b = Array(m, {0}) 
    for(i in 0 until m){
        var (s, t) = readLine()!!.split(" ").map(String::toInt)
        s--
        t--
        a[i] = s
        b[i] = t
    }
    var ans = Array(m, {0.toLong()})
    var tmp = (n.toLong()*(n.toLong()-1))/2.toLong()
    ans[m-1] = tmp
    for(i in m-1 downTo 1){
        if(uf.findSet(a[i], b[i])){
            ans[i-1] = tmp
        }else{
            val sa = uf.size(a[i]).toLong() 
            val sb = uf.size(b[i]).toLong()
            uf.unionSet(a[i], b[i])
            tmp -= sa*sb
            ans[i-1] = tmp
        }
    }
    for(i in 0 until m){
        println(ans[i])
    }
}