n, m =map(int, input().split())

par=[-1]*n

def find(x):
    if par[x]<0: return x
    par[x] = find(par[x])
    return par[x]

def union(x, y):
    p,q=find(x),find(y)
    if p==q: return
    if p>q: p,q=q,p
    par[p] += par[q]
    par[q] = p

def size(x):
    return -par[find(x)]

def same(x,y):
    return find(x)==find(y)

bridge=[0]*m
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    bridge[m-i-1]=(a,b)

sm=(n*(n-1))//2
ans=[0]*m
for i in range(m):
    ans[m-1-i]=sm
    a, b  = bridge[i][0], bridge[i][1]
    p,q=find(a),find(b)
    if p!=q:
        sm -= size(p)*size(q)
    union(a,b)

for i in range(m):
    print(ans[i]) n, m =map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m par=[-1]*n par [-1]*n [-1] -1 n def find(x):
    if par[x]<0: return x
    par[x] = find(par[x])
    return par[x] find if par[x]<0: return x
     par[x]<0 par[x] par x 0 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):
    p,q=find(x),find(y)
    if p==q: return
    if p>q: p,q=q,p
    par[p] += par[q]
    par[q] = p union p,q=find(x),find(y) p find(x) find x q find(y) find y if p==q: return
     p==q p q if p>q: p,q=q,p
     p>q p q par[p] += par[q] par[p] par p par[q] par q par[q] = p par[q] par q p x x y y def size(x):
    return -par[find(x)] size return -par[find(x)] -par[find(x)] par[find(x)] par find(x) find x x x def same(x,y):
    return find(x)==find(y) same return find(x)==find(y) find(x)==find(y) find(x) find x find(y) find y x x y y bridge=[0]*m bridge [0]*m [0] 0 m for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    bridge[m-i-1]=(a,b) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b a-=1 a 1 b-=1 b 1 bridge[m-i-1]=(a,b) bridge[m-i-1] bridge m-i-1 m-i m i 1 (a,b) a b sm=(n*(n-1))//2 sm (n*(n-1))//2 n*(n-1) n n-1 n 1 2 ans=[0]*m ans [0]*m [0] 0 m for i in range(m):
    ans[m-1-i]=sm
    a, b  = bridge[i][0], bridge[i][1]
    p,q=find(a),find(b)
    if p!=q:
        sm -= size(p)*size(q)
    union(a,b) i range(m) range m ans[m-1-i]=sm ans[m-1-i] ans m-1-i m-1 m 1 i sm a, b  = bridge[i][0], bridge[i][1] a bridge[i][0] [i] bridge i 0 b bridge[i][1] [i] bridge i 1 p,q=find(a),find(b) p find(a) find a q find(b) find b if p!=q:
        sm -= size(p)*size(q)
     p!=q p q sm -= size(p)*size(q) sm size(p)*size(q) size(p) size p size(q) size q union(a,b) union a b for i in range(m):
    print(ans[i]) i range(m) range m print(ans[i]) print ans[i] ans i def same(x,y):
    return find(x)==find(y) def same(x,y):
    return find(x)==find(y) same par=[-1]*n [-1]*n par def find(x):
    if par[x]<0: return x
    par[x] = find(par[x])
    return par[x] def find(x):
    if par[x]<0: return x
    par[x] = find(par[x])
    return par[x] find a,b=map(int,input().split()) map(int,input().split()) a sm -= size(p)*size(q) size(p)*size(q) sm b=map(int,input().split()) map(int,input().split()) b a-=1 1 a def union(x, y):
    p,q=find(x),find(y)
    if p==q: return
    if p>q: p,q=q,p
    par[p] += par[q]
    par[q] = p def union(x, y):
    p,q=find(x),find(y)
    if p==q: return
    if p>q: p,q=q,p
    par[p] += par[q]
    par[q] = p union b-=1 1 b b  = bridge[i][0], bridge[i][1] bridge[i][1] b bridge=[0]*m [0]*m bridge a, b  = bridge[i][0], bridge[i][1] bridge[i][0] a sm=(n*(n-1))//2 (n*(n-1))//2 sm q=find(a),find(b) find(b) q ans=[0]*m [0]*m ans m =map(int, input().split()) map(int, input().split()) m p,q=find(a),find(b) find(a) p n, m =map(int, input().split()) map(int, input().split()) n def size(x):
    return -par[find(x)] def size(x):
    return -par[find(x)] size
n, m =map(int, input().split())

par=[-1]*n

def find(x):
    if par[x]<0: return x
    par[x] = find(par[x])
    return par[x]

def union(x, y):
    p,q=find(x),find(y)
    if p==q: return
    if p>q: p,q=q,p
    par[p] += par[q]
    par[q] = p

def size(x):
    return -par[find(x)]

def same(x,y):
    return find(x)==find(y)

bridge=[0]*m
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    bridge[m-i-1]=(a,b)

sm=(n*(n-1))//2
ans=[0]*m
for i in range(m):
    ans[m-1-i]=sm
    a, b  = bridge[i][0], bridge[i][1]
    p,q=find(a),find(b)
    if p!=q:
        sm -= size(p)*size(q)
    union(a,b)

for i in range(m):
    print(ans[i])