class UnionFind():
  def __init__(self,n):
    self.parents = [-1]*n
  
  def find(self,x):
    if self.parents[x] < 0:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
	
    self.parents[x]+=self.parents[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def size(self,x):
    return abs(self.parents[self.find(x)])


N,M=map(int,input().split())
uf = UnionFind(N+1)

cnt=(N)*(N-1)//2
L=[[int(x) for x in input().split()] for _ in range(M)]
ans=[]

for a,b in L[::-1]:
  ans.append(cnt)
  if not uf.same(a,b):
    cnt -= uf.size(a)*uf.size(b)
    uf.union(a,b)

for x in ans[::-1]:
  print(x) class UnionFind():
  def __init__(self,n):
    self.parents = [-1]*n
  
  def find(self,x):
    if self.parents[x] < 0:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
	
    self.parents[x]+=self.parents[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def size(self,x):
    return abs(self.parents[self.find(x)]) UnionFind def __init__(self,n):
    self.parents = [-1]*n
  
   __init__ self.parents = [-1]*n self.parents self parents [-1]*n [-1] -1 n self self n n def find(self,x):
    if self.parents[x] < 0:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
   find if self.parents[x] < 0:
      return x
	
     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
	
    self.parents[x]+=self.parents[y]
    self.parents[y] = x
  
   union x = self.find(x) x self.find(x) self.find self find x y = self.find(y) y self.find(y) self.find self find y if x==y:
      return
    
     x==y x y return if self.parents[x]>self.parents[y]:
      x,y=y,x
	
     self.parents[x]>self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y x,y=y,x x y y x self.parents[x]+=self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y self.parents[y] = x self.parents[y] self.parents self parents y x self self x x y y def same(self,x,y):
    return self.find(x) == self.find(y)
  
   same return self.find(x) == self.find(y) self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y self self x x y y def size(self,x):
    return abs(self.parents[self.find(x)]) size return abs(self.parents[self.find(x)]) abs(self.parents[self.find(x)]) abs self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M uf = UnionFind(N+1) uf UnionFind(N+1) UnionFind N+1 N 1 cnt=(N)*(N-1)//2 cnt (N)*(N-1)//2 (N)*(N-1) N N-1 N 1 2 [int(x) for x in input().split()] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [int(x) for x in input().split()] L=[[int(x) for x in input().split()] for _ in range(M)] L [[int(x) for x in input().split()] for _ in range(M)] ans=[] ans [] for a,b in L[::-1]:
  ans.append(cnt)
  if not uf.same(a,b):
    cnt -= uf.size(a)*uf.size(b)
    uf.union(a,b) a b L[::-1] L ::-1 -1 ans.append(cnt) ans.append ans append cnt if not uf.same(a,b):
    cnt -= uf.size(a)*uf.size(b)
    uf.union(a,b) not uf.same(a,b) uf.same(a,b) uf.same uf same a b cnt -= uf.size(a)*uf.size(b) cnt uf.size(a)*uf.size(b) uf.size(a) uf.size uf size a uf.size(b) uf.size uf size b uf.union(a,b) uf.union uf union a b for x in ans[::-1]:
  print(x) x ans[::-1] ans ::-1 -1 print(x) print x class UnionFind():
  def __init__(self,n):
    self.parents = [-1]*n
  
  def find(self,x):
    if self.parents[x] < 0:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
	
    self.parents[x]+=self.parents[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def size(self,x):
    return abs(self.parents[self.find(x)]) class UnionFind():
  def __init__(self,n):
    self.parents = [-1]*n
  
  def find(self,x):
    if self.parents[x] < 0:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
	
    self.parents[x]+=self.parents[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def size(self,x):
    return abs(self.parents[self.find(x)]) UnionFind cnt=(N)*(N-1)//2 (N)*(N-1)//2 cnt M=map(int,input().split()) map(int,input().split()) M ans=[] [] ans cnt -= uf.size(a)*uf.size(b) uf.size(a)*uf.size(b) cnt uf = UnionFind(N+1) UnionFind(N+1) uf L=[[int(x) for x in input().split()] for _ in range(M)] [[int(x) for x in input().split()] for _ in range(M)] L N,M=map(int,input().split()) map(int,input().split()) N
class UnionFind():
  def __init__(self,n):
    self.parents = [-1]*n
  
  def find(self,x):
    if self.parents[x] < 0:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
	
    self.parents[x]+=self.parents[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def size(self,x):
    return abs(self.parents[self.find(x)])


N,M=map(int,input().split())
uf = UnionFind(N+1)

cnt=(N)*(N-1)//2
L=[[int(x) for x in input().split()] for _ in range(M)]
ans=[]

for a,b in L[::-1]:
  ans.append(cnt)
  if not uf.same(a,b):
    cnt -= uf.size(a)*uf.size(b)
    uf.union(a,b)

for x in ans[::-1]:
  print(x)