N,M=map(int,input().split())
bridge=[]
for i in range(M):
  a,b=map(int,input().split())
  bridge.append((a-1,b-1))
bridge.reverse()
par=[i for i in range(N)]
size=[1 for i in range(N)]
def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def union(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return
now=int(N*(N-1)/2)
ans=[]
ans.append(now)
for i in range(M-1):
  a=bridge[i][0]
  b=bridge[i][1]
  if find(a)==find(b):
    ans.append(now)
  else:
    now-=size[find(a)]*size[find(b)]
    ans.append(now)
  union(a,b)
ans.reverse()
print(*ans) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M bridge=[] bridge [] for i in range(M):
  a,b=map(int,input().split())
  bridge.append((a-1,b-1)) i range(M) range M a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b bridge.append((a-1,b-1)) bridge.append bridge append (a-1,b-1) a-1 a 1 b-1 b 1 bridge.reverse() bridge.reverse bridge reverse 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)] 1 for i in range(N) for i in range(N) i range(N) range N for i in range(N) 1 size=[1 for i in range(N)] size [1 for i in range(N)] def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x] find if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x] par[x]==x par[x] par x x return x 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(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return union x=find(a) x find(a) find a y=find(b) y find(b) find b if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return x!=y x y if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
   size[x]<size[y] size[x] size x size[y] size y par[x]=par[y] par[x] par x par[y] par y size[y]+=size[x] size[y] size y size[x] size x par[y]=par[x] par[y] par y par[x] par x size[x]+=size[y] size[x] size x size[y] size y return a a b b now=int(N*(N-1)/2) now int(N*(N-1)/2) int N*(N-1)/2 N*(N-1) N N-1 N 1 2 ans=[] ans [] ans.append(now) ans.append ans append now for i in range(M-1):
  a=bridge[i][0]
  b=bridge[i][1]
  if find(a)==find(b):
    ans.append(now)
  else:
    now-=size[find(a)]*size[find(b)]
    ans.append(now)
  union(a,b) i range(M-1) range M-1 M 1 a=bridge[i][0] a bridge[i][0] [i] bridge i 0 b=bridge[i][1] b bridge[i][1] [i] bridge i 1 if find(a)==find(b):
    ans.append(now)
  else:
    now-=size[find(a)]*size[find(b)]
    ans.append(now)
   find(a)==find(b) find(a) find a find(b) find b ans.append(now) ans.append ans append now now-=size[find(a)]*size[find(b)] now size[find(a)]*size[find(b)] size[find(a)] size find(a) find a size[find(b)] size find(b) find b ans.append(now) ans.append ans append now union(a,b) union a b ans.reverse() ans.reverse ans reverse print(*ans) print *ans ans M=map(int,input().split()) map(int,input().split()) M a,b=map(int,input().split()) map(int,input().split()) a now=int(N*(N-1)/2) int(N*(N-1)/2) now a=bridge[i][0] bridge[i][0] a def union(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return def union(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return union ans=[] [] ans par=[i for i in range(N)] [i for i in range(N)] par bridge=[] [] bridge b=map(int,input().split()) map(int,input().split()) b size=[1 for i in range(N)] [1 for i in range(N)] size b=bridge[i][1] bridge[i][1] b now-=size[find(a)]*size[find(b)] size[find(a)]*size[find(b)] now def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x] def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x] find N,M=map(int,input().split()) map(int,input().split()) N
N,M=map(int,input().split())
bridge=[]
for i in range(M):
  a,b=map(int,input().split())
  bridge.append((a-1,b-1))
bridge.reverse()
par=[i for i in range(N)]
size=[1 for i in range(N)]
def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def union(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return
now=int(N*(N-1)/2)
ans=[]
ans.append(now)
for i in range(M-1):
  a=bridge[i][0]
  b=bridge[i][1]
  if find(a)==find(b):
    ans.append(now)
  else:
    now-=size[find(a)]*size[find(b)]
    ans.append(now)
  union(a,b)
ans.reverse()
print(*ans)