import sys, queue, math, copy, itertools, bisect, collections, heapq
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
_LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()]
NI = lambda: int(sys.stdin.readline())

N, M = LI()
bridge = [_LI() for _ in range(M)]

g = [i for i in range(N)]
g_num = [1 for _ in range(N)]

def find(node):
    if g[node] == node: return node
    g[node] = find(g[node])
    return g[node]

def union(x,y):
#    if find(x) == find(y) : return
    if g_num[g[x]] > g_num[g[y]]: x,y = y,x
    g_num[g[y]] += g_num[g[x]]
    g[g[x]] = g[y]

benri = [0] * M
for i in range(M-1,-1,-1):
    x, y = bridge[i]
    if find(x) == find(y): continue
    benri[i] = g_num[g[x]] * g_num[g[y]]
    union(x,y)
ans = 0
for b in benri:
    ans += b
    print (ans) import sys, queue, math, copy, itertools, bisect, collections, heapq sys queue math copy itertools bisect collections heapq int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda: [int(x) for x in sys.stdin.readline().split()] LI lambda: [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] int(x) - 1 for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) - 1 int(x) int x 1 _LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()] _LI lambda: [int(x) - 1 for x in sys.stdin.readline().split()] [int(x) - 1 for x in sys.stdin.readline().split()] NI = lambda: int(sys.stdin.readline()) NI lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline N, M = LI() N LI() LI M _LI() for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) _LI() _LI bridge = [_LI() for _ in range(M)] bridge [_LI() for _ in range(M)] i for i in range(N) for i in range(N) i range(N) range N for i in range(N) i g = [i for i in range(N)] g [i for i in range(N)] 1 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 1 g_num = [1 for _ in range(N)] g_num [1 for _ in range(N)] def find(node):
    if g[node] == node: return node
    g[node] = find(g[node])
    return g[node] find if g[node] == node: return node
     g[node] == node g[node] g node node g[node] = find(g[node]) g[node] g node find(g[node]) find g[node] g node return g[node] g[node] g node node node def union(x,y):
#    if find(x) == find(y) : return
    if g_num[g[x]] > g_num[g[y]]: x,y = y,x
    g_num[g[y]] += g_num[g[x]]
    g[g[x]] = g[y] union if g_num[g[x]] > g_num[g[y]]: x,y = y,x
     g_num[g[x]] > g_num[g[y]] g_num[g[x]] g_num g[x] g x g_num[g[y]] g_num g[y] g y g_num[g[y]] += g_num[g[x]] g_num[g[y]] g_num g[y] g y g_num[g[x]] g_num g[x] g x g[g[x]] = g[y] g[g[x]] g g[x] g x g[y] g y x x y y benri = [0] * M benri [0] * M [0] 0 M for i in range(M-1,-1,-1):
    x, y = bridge[i]
    if find(x) == find(y): continue
    benri[i] = g_num[g[x]] * g_num[g[y]]
    union(x,y) i range(M-1,-1,-1) range M-1 M 1 -1 -1 x, y = bridge[i] x bridge[i] bridge i y if find(x) == find(y): continue
     find(x) == find(y) find(x) find x find(y) find y benri[i] = g_num[g[x]] * g_num[g[y]] benri[i] benri i g_num[g[x]] * g_num[g[y]] g_num[g[x]] g_num g[x] g x g_num[g[y]] g_num g[y] g y union(x,y) union x y ans = 0 ans 0 for b in benri:
    ans += b
    print (ans) b benri ans += b ans b print (ans) print ans LI = lambda: [int(x) for x in sys.stdin.readline().split()] lambda: [int(x) for x in sys.stdin.readline().split()] LI g = [i for i in range(N)] [i for i in range(N)] g NI = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) NI N, M = LI() LI() N M = LI() LI() M benri = [0] * M [0] * M benri y = bridge[i] bridge[i] y _LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()] lambda: [int(x) - 1 for x in sys.stdin.readline().split()] _LI g_num = [1 for _ in range(N)] [1 for _ in range(N)] g_num bridge = [_LI() for _ in range(M)] [_LI() for _ in range(M)] bridge def find(node):
    if g[node] == node: return node
    g[node] = find(g[node])
    return g[node] def find(node):
    if g[node] == node: return node
    g[node] = find(g[node])
    return g[node] find def union(x,y):
#    if find(x) == find(y) : return
    if g_num[g[x]] > g_num[g[y]]: x,y = y,x
    g_num[g[y]] += g_num[g[x]]
    g[g[x]] = g[y] def union(x,y):
#    if find(x) == find(y) : return
    if g_num[g[x]] > g_num[g[y]]: x,y = y,x
    g_num[g[y]] += g_num[g[x]]
    g[g[x]] = g[y] union ans += b b ans x, y = bridge[i] bridge[i] x ans = 0 0 ans
import sys, queue, math, copy, itertools, bisect, collections, heapq
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
_LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()]
NI = lambda: int(sys.stdin.readline())

N, M = LI()
bridge = [_LI() for _ in range(M)]

g = [i for i in range(N)]
g_num = [1 for _ in range(N)]

def find(node):
    if g[node] == node: return node
    g[node] = find(g[node])
    return g[node]

def union(x,y):
#    if find(x) == find(y) : return
    if g_num[g[x]] > g_num[g[y]]: x,y = y,x
    g_num[g[y]] += g_num[g[x]]
    g[g[x]] = g[y]

benri = [0] * M
for i in range(M-1,-1,-1):
    x, y = bridge[i]
    if find(x) == find(y): continue
    benri[i] = g_num[g[x]] * g_num[g[y]]
    union(x,y)
ans = 0
for b in benri:
    ans += b
    print (ans)
