import java.util.*

class Bridge(a: Int, b: Int) {
    val a = a
    val b = b
}

class Island(parent: Int, depth: Int, size: Int) {
    var parent = parent
    var depth = depth
    var size = size
}

fun root(i: Int, a: Array<Island>): Int {
    var now: Int = i
    while (a[now].parent != -1) {
        now = a[now].parent
    }
    return now
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val m = cin.nextInt()
    
    val arr = Array<Bridge>(m, { Bridge(cin.nextInt() - 1, cin.nextInt() - 1) })

    val unionfind = Array<Island>(n, { Island(-1, 1, 1) })

    val inconvenient = Array<Long>(m, { 0 })

    inconvenient[m - 1] = n.toLong() * (n - 1).toLong() / 2

    for (i in 0..m-1) {
        val j = m - 1 - i
        val ia = arr[j].a
        val ib = arr[j].b

        val ix = root(ia, unionfind)
        val iy = root(ib, unionfind)

        if (ix == iy) {
            if (j != 0) {
                inconvenient[j - 1] = inconvenient[j]
            }
            continue
        }

        val along: Long = unionfind[ix].size.toLong() * unionfind[iy].size.toLong()
        if (j != 0) {
            inconvenient[j - 1] = inconvenient[j] - along
        }

        if (unionfind[iy].depth > unionfind[ix].depth) {
            unionfind[ix].parent = iy
            unionfind[iy].size += unionfind[ix].size
        } else {
            unionfind[iy].parent = ix
            unionfind[ix].size += unionfind[iy].size
            if (unionfind[ix].depth == unionfind[iy].depth) {
                unionfind[ix].depth += 1
            }
        }
    }

    for (i in 0..m-1) {
        println(inconvenient[i])
    }
}