import java.util.*
import java.math.*
import java.lang.Math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private val MOD = 1e9.toLong()+7


class UnionFind(val N: Int) {
    private var dt = arrayOf<Int>()
    init {
        this.dt = Array<Int>(N+1){-1}
    }
    tailrec fun root(key: Int): Int {
        if (this.dt[key] < 0) {
            return key
        } else {
            this.dt[key] = this.root(this.dt[key])
            return this.dt[key]
        }
    }
    fun unite(KX: Int, KY: Int): Boolean {
        var kx = this.root(KX); var ky = this.root(KY)
        if (kx == ky) {
            return false
        }
        if (this.size(kx) < this.size(ky)) {
            val tmp = kx
            kx = ky
            ky = tmp
        }
        this.dt[kx] += this.dt[ky]
        this.dt[ky] = kx
        return true;
    }
    fun size(key: Int): Int {
        val rk = this.root(key)
        return -this.dt[rk]
    }
    fun isConnect(kx: Int, ky: Int): Boolean {
        return this.root(kx) == this.root(ky)
    }
}


fun solveD(N: Int, M: Int, AB: Array<Pair<Int,Int>>): Array<Long> {
    val uf = UnionFind(N)
    val ans = Array<Long>(M+1){0L}
    ans[M] = N.toLong()*(N-1)/2

    for(i in M-1 downTo 0) {
        val pr = AB[i]
        if (uf.isConnect(pr.first, pr.second)) {
            ans[i] = ans[i+1]
        } else {
            ans[i] = max(0L, ans[i + 1] - uf.size(pr.first).toLong() * uf.size(pr.second))
            uf.unite(pr.first, pr.second)
        }
    }

    return ans
}


fun main(args: Array<String>) {
    val (N, M) = readListInt()
    val AB = Array(M){Pair(0,0)}
    for(i in 0 until M) {
        val (A,B) = readListInt().map { it -1 }
        AB[i] = Pair(A,B)
    }

    val ans = solveD(N, M, AB)

    for (i in 1..M) {
        println(ans[i])
    }
}
