n,m=map(int,input().split())
d=[-1]*n
def find(x):
    if d[x]<0:
        return x
    d[x]=find(d[x])
    return d[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if d[x]>d[y]:
        x,y=y,x
    d[x]+=d[y]
    d[y]=x
    return
ans=(int)(n*(n-1)/2)
a=[0]*m
b=[0]*m
stack=[]
for i in range(m):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
a.reverse()
b.reverse()
for i in range(m):
    stack.append(ans)
    a[i]=find(a[i])
    b[i]=find(b[i])
    if find(a[i])!=find(b[i]):
        ans-=(int)(-d[a[i]])*(-d[b[i]])
        unite(a[i],b[i])
while stack:
    print(stack.pop()) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m d=[-1]*n d [-1]*n [-1] -1 n def find(x):
    if d[x]<0:
        return x
    d[x]=find(d[x])
    return d[x] find if d[x]<0:
        return x
     d[x]<0 d[x] d x 0 return x x d[x]=find(d[x]) d[x] d x find(d[x]) find d[x] d x return d[x] d[x] d x x x def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if d[x]>d[y]:
        x,y=y,x
    d[x]+=d[y]
    d[y]=x
    return unite x=find(x) x find(x) find x y=find(y) y find(y) find y if x==y:
        return
     x==y x y return if d[x]>d[y]:
        x,y=y,x
     d[x]>d[y] d[x] d x d[y] d y x,y=y,x x y y x d[x]+=d[y] d[x] d x d[y] d y d[y]=x d[y] d y x return x x y y ans=(int)(n*(n-1)/2) ans (int)(n*(n-1)/2) int n*(n-1)/2 n*(n-1) n n-1 n 1 2 a=[0]*m a [0]*m [0] 0 m b=[0]*m b [0]*m [0] 0 m stack=[] stack [] for i in range(m):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1 i range(m) range m a[i],b[i]=map(int,input().split()) a[i] a i map(int,input().split()) map int input().split() ().split () input split b[i] b i a[i]-=1 a[i] a i 1 b[i]-=1 b[i] b i 1 a.reverse() a.reverse a reverse b.reverse() b.reverse b reverse for i in range(m):
    stack.append(ans)
    a[i]=find(a[i])
    b[i]=find(b[i])
    if find(a[i])!=find(b[i]):
        ans-=(int)(-d[a[i]])*(-d[b[i]])
        unite(a[i],b[i]) i range(m) range m stack.append(ans) stack.append stack append ans a[i]=find(a[i]) a[i] a i find(a[i]) find a[i] a i b[i]=find(b[i]) b[i] b i find(b[i]) find b[i] b i if find(a[i])!=find(b[i]):
        ans-=(int)(-d[a[i]])*(-d[b[i]])
        unite(a[i],b[i]) find(a[i])!=find(b[i]) find(a[i]) find a[i] a i find(b[i]) find b[i] b i ans-=(int)(-d[a[i]])*(-d[b[i]]) ans (int)(-d[a[i]])*(-d[b[i]]) (int)(-d[a[i]]) int -d[a[i]] d[a[i]] d a[i] a i -d[b[i]] d[b[i]] d b[i] b i unite(a[i],b[i]) unite a[i] a i b[i] b i while stack:
    print(stack.pop()) stack print(stack.pop()) print stack.pop() stack.pop stack pop m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n b=[0]*m [0]*m b def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if d[x]>d[y]:
        x,y=y,x
    d[x]+=d[y]
    d[y]=x
    return def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if d[x]>d[y]:
        x,y=y,x
    d[x]+=d[y]
    d[y]=x
    return unite ans=(int)(n*(n-1)/2) (int)(n*(n-1)/2) ans def find(x):
    if d[x]<0:
        return x
    d[x]=find(d[x])
    return d[x] def find(x):
    if d[x]<0:
        return x
    d[x]=find(d[x])
    return d[x] find d=[-1]*n [-1]*n d stack=[] [] stack ans-=(int)(-d[a[i]])*(-d[b[i]]) (int)(-d[a[i]])*(-d[b[i]]) ans a=[0]*m [0]*m a
n,m=map(int,input().split())
d=[-1]*n
def find(x):
    if d[x]<0:
        return x
    d[x]=find(d[x])
    return d[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if d[x]>d[y]:
        x,y=y,x
    d[x]+=d[y]
    d[y]=x
    return
ans=(int)(n*(n-1)/2)
a=[0]*m
b=[0]*m
stack=[]
for i in range(m):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
a.reverse()
b.reverse()
for i in range(m):
    stack.append(ans)
    a[i]=find(a[i])
    b[i]=find(b[i])
    if find(a[i])!=find(b[i]):
        ans-=(int)(-d[a[i]])*(-d[b[i]])
        unite(a[i],b[i])
while stack:
    print(stack.pop())