from collections import defaultdict

class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
def comb2(n):
  return n*(n-1)//2
    
N,M=map(int,input().split())
E = [tuple(map(int,input().split())) for _ in range(M)]

total=comb2(N)
uf = UnionFind(N+1)
ans = [total]
for i in range(M-1):
  a,b = E[-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
    continue
  else:
    size1,size2 = uf.size(a),uf.size(b)
    uf.unite(a,b)
    size3 = uf.size(a)
    tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3)
    ans.append(tmp)
print(*ans[::-1]) from collections import defaultdict class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
     UnionFind def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
     __init__ self.d = [-1]*n self.d self d [-1]*n [-1] -1 n self.g = set() self.g self g set() set self self n=0 n 0 def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

     find if self.d[x] < 0: return x
         self.d[x] < 0 self.d[x] self.d self d x 0 self.d[x] = self.find(self.d[x]) self.d[x] self.d self d x self.find(self.d[x]) self.find self find self.d[x] self.d self d x return self.d[x] self.d[x] self.d self d x self self x x def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

     unite x,y=self.find(x),self.find(y) x self.find(x) self.find self find x y self.find(y) self.find self find y if x==y:return False
         x==y x y if self.d[x] > self.d[y]: x,y=y,x
         self.d[x] > self.d[y] self.d[x] self.d self d x self.d[y] self.d self d y self.d[x] += self.d[y] self.d[x] self.d self d x self.d[y] self.d self d y self.g.add(x) self.g.add self.g self g add x if y in self.g:self.g.remove(y)
         y in self.g y self.g self g self.d[y] = x self.d[y] self.d self d y x return True True self self x x y y def same(self,x,y): return self.find(x)==self.find(y)
     same self self x x y y def size(self,x): return -self.d[self.find(x)]
     size self self x x def comb2(n):
  return n*(n-1)//2
     comb2 return n*(n-1)//2 n*(n-1)//2 n*(n-1) n n-1 n 1 2 n n N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M tuple(map(int,input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split E = [tuple(map(int,input().split())) for _ in range(M)] E [tuple(map(int,input().split())) for _ in range(M)] total=comb2(N) total comb2(N) comb2 N uf = UnionFind(N+1) uf UnionFind(N+1) UnionFind N+1 N 1 ans = [total] ans [total] total for i in range(M-1):
  a,b = E[-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
    continue
  else:
    size1,size2 = uf.size(a),uf.size(b)
    uf.unite(a,b)
    size3 = uf.size(a)
    tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3)
    ans.append(tmp) i range(M-1) range M-1 M 1 a,b = E[-i-1] a E[-i-1] E -i-1 -i i 1 b if uf.same(a,b):
    ans.append(ans[-1])
    continue
  else:
    size1,size2 = uf.size(a),uf.size(b)
    uf.unite(a,b)
    size3 = uf.size(a)
    tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3)
    ans.append(tmp) uf.same(a,b) uf.same uf same a b ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 continue size1,size2 = uf.size(a),uf.size(b) size1 uf.size(a) uf.size uf size a size2 uf.size(b) uf.size uf size b uf.unite(a,b) uf.unite uf unite a b size3 = uf.size(a) size3 uf.size(a) uf.size uf size a tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3) tmp ans[-1]+comb2(size1)+comb2(size2)-comb2(size3) ans[-1]+comb2(size1)+comb2(size2) ans[-1]+comb2(size1) ans[-1] ans -1 comb2(size1) comb2 size1 comb2(size2) comb2 size2 comb2(size3) comb2 size3 ans.append(tmp) ans.append ans append tmp print(*ans[::-1]) print *ans[::-1] ans[::-1] ans ::-1 -1 E = [tuple(map(int,input().split())) for _ in range(M)] [tuple(map(int,input().split())) for _ in range(M)] E size1,size2 = uf.size(a),uf.size(b) uf.size(a) size1 def comb2(n):
  return n*(n-1)//2
     def comb2(n):
  return n*(n-1)//2
     comb2 tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3) ans[-1]+comb2(size1)+comb2(size2)-comb2(size3) tmp b = E[-i-1] E[-i-1] b a,b = E[-i-1] E[-i-1] a class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
     class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
     UnionFind size2 = uf.size(a),uf.size(b) uf.size(b) size2 N,M=map(int,input().split()) map(int,input().split()) N size3 = uf.size(a) uf.size(a) size3 M=map(int,input().split()) map(int,input().split()) M ans = [total] [total] ans uf = UnionFind(N+1) UnionFind(N+1) uf total=comb2(N) comb2(N) total
from collections import defaultdict

class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
def comb2(n):
  return n*(n-1)//2
    
N,M=map(int,input().split())
E = [tuple(map(int,input().split())) for _ in range(M)]

total=comb2(N)
uf = UnionFind(N+1)
ans = [total]
for i in range(M-1):
  a,b = E[-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
    continue
  else:
    size1,size2 = uf.size(a),uf.size(b)
    uf.unite(a,b)
    size3 = uf.size(a)
    tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3)
    ans.append(tmp)
print(*ans[::-1])