
import sys
sys.setrecursionlimit(10**9)


def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p]

def resolve():
    n,m = map(int, input().split())
    bridges = [list(map(lambda x: int(x)-1, input().split())) for i in range(m)]

    graph = {}
    # if a not in graph:
    #     graph[a] = {}
    # if b not in graph:
    #     graph[b] = {}
    # graph[a][b] = graph[b][a] = 1
    tmp = n * (n-1) // 2
    ans = [tmp]
    append=ans.append
    cnt = [1 for _ in range(n)]
    par = [i for i in range(n)]

    for i in range(m)[::-1]:
        a,b = bridges[i]
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            append(tmp)
            continue
        # unite
        tmp -= cnt[aa] * cnt[bb]
        append(tmp)
        if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

    [print(i) for i in ans[:-1][::-1]]


if __name__ == '__main__':
    resolve() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i) unite j = get_par(par, j) j get_par(par, j) get_par par j par[j] = get_par(par, i) par[j] par j get_par(par, i) get_par par i par par i i j j def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p] get_par while par[p] != p:
        p = par[p]
     par[p] != p par[p] par p p p = par[p] p par[p] par p return par[p] par[p] par p par par p p def resolve():
    n,m = map(int, input().split())
    bridges = [list(map(lambda x: int(x)-1, input().split())) for i in range(m)]

    graph = {}
    # if a not in graph:
    #     graph[a] = {}
    # if b not in graph:
    #     graph[b] = {}
    # graph[a][b] = graph[b][a] = 1
    tmp = n * (n-1) // 2
    ans = [tmp]
    append=ans.append
    cnt = [1 for _ in range(n)]
    par = [i for i in range(n)]

    for i in range(m)[::-1]:
        a,b = bridges[i]
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            append(tmp)
            continue
        # unite
        tmp -= cnt[aa] * cnt[bb]
        append(tmp)
        if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

    [print(i) for i in ans[:-1][::-1]] resolve n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(lambda x: int(x)-1, input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(lambda x: int(x)-1, input().split())) list map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split bridges = [list(map(lambda x: int(x)-1, input().split())) for i in range(m)] bridges [list(map(lambda x: int(x)-1, input().split())) for i in range(m)] graph = {} graph {} tmp = n * (n-1) // 2 tmp n * (n-1) // 2 n * (n-1) n n-1 n 1 2 ans = [tmp] ans [tmp] tmp append=ans.append append ans.append ans append 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 cnt = [1 for _ in range(n)] cnt [1 for _ in range(n)] i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i par = [i for i in range(n)] par [i for i in range(n)] for i in range(m)[::-1]:
        a,b = bridges[i]
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            append(tmp)
            continue
        # unite
        tmp -= cnt[aa] * cnt[bb]
        append(tmp)
        if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

     i range(m)[::-1] (m) range m ::-1 -1 a,b = bridges[i] a bridges[i] bridges i b aa = get_par(par, a) aa get_par(par, a) get_par par a bb = get_par(par, b) bb get_par(par, b) get_par par b if aa == bb:
            append(tmp)
            continue
        # unite
         aa == bb aa bb append(tmp) append tmp continue tmp -= cnt[aa] * cnt[bb] tmp cnt[aa] * cnt[bb] cnt[aa] cnt aa cnt[bb] cnt bb append(tmp) append tmp if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

     cnt[aa] > cnt[bb] cnt[aa] cnt aa cnt[bb] cnt bb par[bb] = aa par[bb] par bb aa cnt[aa] += cnt[bb] cnt[aa] cnt aa cnt[bb] cnt bb par[aa] = bb par[aa] par aa bb cnt[bb] += cnt[aa] cnt[bb] cnt bb cnt[aa] cnt aa print(i) for i in ans[:-1][::-1] for i in ans[:-1][::-1] i ans[:-1][::-1] [:-1] ans :-1 -1 ::-1 -1 for i in ans[:-1][::-1] print(i) print i [print(i) for i in ans[:-1][::-1]] if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p] def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p] get_par def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i) def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i) unite def resolve():
    n,m = map(int, input().split())
    bridges = [list(map(lambda x: int(x)-1, input().split())) for i in range(m)]

    graph = {}
    # if a not in graph:
    #     graph[a] = {}
    # if b not in graph:
    #     graph[b] = {}
    # graph[a][b] = graph[b][a] = 1
    tmp = n * (n-1) // 2
    ans = [tmp]
    append=ans.append
    cnt = [1 for _ in range(n)]
    par = [i for i in range(n)]

    for i in range(m)[::-1]:
        a,b = bridges[i]
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            append(tmp)
            continue
        # unite
        tmp -= cnt[aa] * cnt[bb]
        append(tmp)
        if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

    [print(i) for i in ans[:-1][::-1]] def resolve():
    n,m = map(int, input().split())
    bridges = [list(map(lambda x: int(x)-1, input().split())) for i in range(m)]

    graph = {}
    # if a not in graph:
    #     graph[a] = {}
    # if b not in graph:
    #     graph[b] = {}
    # graph[a][b] = graph[b][a] = 1
    tmp = n * (n-1) // 2
    ans = [tmp]
    append=ans.append
    cnt = [1 for _ in range(n)]
    par = [i for i in range(n)]

    for i in range(m)[::-1]:
        a,b = bridges[i]
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            append(tmp)
            continue
        # unite
        tmp -= cnt[aa] * cnt[bb]
        append(tmp)
        if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

    [print(i) for i in ans[:-1][::-1]] resolve

import sys
sys.setrecursionlimit(10**9)


def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p]

def resolve():
    n,m = map(int, input().split())
    bridges = [list(map(lambda x: int(x)-1, input().split())) for i in range(m)]

    graph = {}
    # if a not in graph:
    #     graph[a] = {}
    # if b not in graph:
    #     graph[b] = {}
    # graph[a][b] = graph[b][a] = 1
    tmp = n * (n-1) // 2
    ans = [tmp]
    append=ans.append
    cnt = [1 for _ in range(n)]
    par = [i for i in range(n)]

    for i in range(m)[::-1]:
        a,b = bridges[i]
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            append(tmp)
            continue
        # unite
        tmp -= cnt[aa] * cnt[bb]
        append(tmp)
        if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

    [print(i) for i in ans[:-1][::-1]]


if __name__ == '__main__':
    resolve()
