n,m = map(int,input().split())
edges = []
for _ in range(m):
    edges.append(list(map(int,input().split())))
ans = []
cur = ((n-1)*n)//2
par = {i:i for i in range(1,n+1)}
size = {i:1 for i in range(1,n+1)}
rank = {i:0 for i in range(1,n+1)}
def find(x):
    if x != par[x]:
        par[x] = find(par[x])
    return par[x]

def union(x,y):
    px,py = find(x),find(y)
    res = 0
    if px != py:
        res = size[px] * size[py]
        if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
    return res

for i in range(m-1,-1,-1):
    ans.append(cur)
    x,y = edges[i]
    cur -= union(x,y)
for i in range(m-1,-1,-1):
    print(ans[i]) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m edges = [] edges [] for _ in range(m):
    edges.append(list(map(int,input().split()))) _ range(m) range m edges.append(list(map(int,input().split()))) edges.append edges append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans = [] ans [] cur = ((n-1)*n)//2 cur ((n-1)*n)//2 (n-1)*n n-1 n 1 n 2 i:i for i in range(1,n+1) for i in range(1,n+1) i range(1,n+1) range 1 n+1 n 1 for i in range(1,n+1) i i par = {i:i for i in range(1,n+1)} par {i:i for i in range(1,n+1)} i:1 for i in range(1,n+1) for i in range(1,n+1) i range(1,n+1) range 1 n+1 n 1 for i in range(1,n+1) i 1 size = {i:1 for i in range(1,n+1)} size {i:1 for i in range(1,n+1)} i:0 for i in range(1,n+1) for i in range(1,n+1) i range(1,n+1) range 1 n+1 n 1 for i in range(1,n+1) i 0 rank = {i:0 for i in range(1,n+1)} rank {i:0 for i in range(1,n+1)} def find(x):
    if x != par[x]:
        par[x] = find(par[x])
    return par[x] find if x != par[x]:
        par[x] = find(par[x])
     x != par[x] x par[x] par x par[x] = find(par[x]) par[x] par x find(par[x]) find par[x] par x return par[x] par[x] par x x x def union(x,y):
    px,py = find(x),find(y)
    res = 0
    if px != py:
        res = size[px] * size[py]
        if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
    return res union px,py = find(x),find(y) px find(x) find x py find(y) find y res = 0 res 0 if px != py:
        res = size[px] * size[py]
        if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
     px != py px py res = size[px] * size[py] res size[px] * size[py] size[px] size px size[py] size py if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
     rank[px] < rank[py] rank[px] rank px rank[py] rank py par[px] = py par[px] par px py size[py] += size[px] size[py] size py size[px] size px par[py] = px par[py] par py px size[px] += size[py] size[px] size px size[py] size py if rank[px] == rank[py]:
                rank[px] += 1
     rank[px] == rank[py] rank[px] rank px rank[py] rank py rank[px] += 1 rank[px] rank px 1 return res res x x y y for i in range(m-1,-1,-1):
    ans.append(cur)
    x,y = edges[i]
    cur -= union(x,y) i range(m-1,-1,-1) range m-1 m 1 -1 -1 ans.append(cur) ans.append ans append cur x,y = edges[i] x edges[i] edges i y cur -= union(x,y) cur union(x,y) union x y for i in range(m-1,-1,-1):
    print(ans[i]) i range(m-1,-1,-1) range m-1 m 1 -1 -1 print(ans[i]) print ans[i] ans i m = map(int,input().split()) map(int,input().split()) m edges = [] [] edges size = {i:1 for i in range(1,n+1)} {i:1 for i in range(1,n+1)} size def find(x):
    if x != par[x]:
        par[x] = find(par[x])
    return par[x] def find(x):
    if x != par[x]:
        par[x] = find(par[x])
    return par[x] find y = edges[i] edges[i] y ans = [] [] ans par = {i:i for i in range(1,n+1)} {i:i for i in range(1,n+1)} par n,m = map(int,input().split()) map(int,input().split()) n x,y = edges[i] edges[i] x rank = {i:0 for i in range(1,n+1)} {i:0 for i in range(1,n+1)} rank def union(x,y):
    px,py = find(x),find(y)
    res = 0
    if px != py:
        res = size[px] * size[py]
        if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
    return res def union(x,y):
    px,py = find(x),find(y)
    res = 0
    if px != py:
        res = size[px] * size[py]
        if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
    return res union cur = ((n-1)*n)//2 ((n-1)*n)//2 cur cur -= union(x,y) union(x,y) cur
n,m = map(int,input().split())
edges = []
for _ in range(m):
    edges.append(list(map(int,input().split())))
ans = []
cur = ((n-1)*n)//2
par = {i:i for i in range(1,n+1)}
size = {i:1 for i in range(1,n+1)}
rank = {i:0 for i in range(1,n+1)}
def find(x):
    if x != par[x]:
        par[x] = find(par[x])
    return par[x]

def union(x,y):
    px,py = find(x),find(y)
    res = 0
    if px != py:
        res = size[px] * size[py]
        if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
    return res

for i in range(m-1,-1,-1):
    ans.append(cur)
    x,y = edges[i]
    cur -= union(x,y)
for i in range(m-1,-1,-1):
    print(ans[i])