from itertools import combinations
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n,m=map(int,input().split())
uf=UnionFind(n)
e=[]
ans=[]
for _ in range(m):
  a,b=map(int,input().split())
  e.append((a,b))
n_m=n*(n-1)//2
for i,j in e[::-1]:
  ans.append(n_m)
  if not uf.isSameGroup(i,j):
    k=uf.Count(i)*uf.Count(j)
    n_m-=k
    uf.Unite(i,j)
for i in ans[::-1]:
  print(i) from itertools import combinations class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)] UnionFind def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
     __init__ self.n = n self.n self n n self.root = [-1]*(n+1) self.root self root [-1]*(n+1) [-1] -1 n+1 n 1 self.rnk = [0]*(n+1) self.rnk self rnk [0]*(n+1) [0] 0 n+1 n 1 self self n n def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
     Find_Root if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
     self.root[x] < 0 self.root[x] self.root self root x 0 return x x self.root[x] = self.Find_Root(self.root[x]) self.root[x] self.root self root x self.Find_Root(self.root[x]) self.Find_Root self Find_Root self.root[x] self.root self root x return self.root[x] self.root[x] self.root self root x self self x x def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
     Unite x = self.Find_Root(x) x self.Find_Root(x) self.Find_Root self Find_Root x y = self.Find_Root(y) y self.Find_Root(y) self.Find_Root self Find_Root y if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
     x == y x y return elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
         self.rnk[x] > self.rnk[y] self.rnk[x] self.rnk self rnk x self.rnk[y] self.rnk self rnk y self.root[x] += self.root[y] self.root[x] self.root self root x self.root[y] self.root self root y self.root[y] = x self.root[y] self.root self root y x self.root[y] += self.root[x] self.root[y] self.root self root y self.root[x] self.root self root x self.root[x] = y self.root[x] self.root self root x y if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
     self.rnk[x] == self.rnk[y] self.rnk[x] self.rnk self rnk x self.rnk[y] self.rnk self rnk y self.rnk[y] += 1 self.rnk[y] self.rnk self rnk y 1 self self x x y y def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
     isSameGroup return self.Find_Root(x) == self.Find_Root(y) self.Find_Root(x) == self.Find_Root(y) self.Find_Root(x) self.Find_Root self Find_Root x self.Find_Root(y) self.Find_Root self Find_Root y self self x x y y def Count(self, x):
        return -self.root[self.Find_Root(x)] Count return -self.root[self.Find_Root(x)] -self.root[self.Find_Root(x)] self.root[self.Find_Root(x)] self.root self root self.Find_Root(x) self.Find_Root self Find_Root 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) uf UnionFind(n) UnionFind n e=[] e [] ans=[] ans [] for _ in range(m):
  a,b=map(int,input().split())
  e.append((a,b)) _ range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b e.append((a,b)) e.append e append (a,b) a b n_m=n*(n-1)//2 n_m n*(n-1)//2 n*(n-1) n n-1 n 1 2 for i,j in e[::-1]:
  ans.append(n_m)
  if not uf.isSameGroup(i,j):
    k=uf.Count(i)*uf.Count(j)
    n_m-=k
    uf.Unite(i,j) i j e[::-1] e ::-1 -1 ans.append(n_m) ans.append ans append n_m if not uf.isSameGroup(i,j):
    k=uf.Count(i)*uf.Count(j)
    n_m-=k
    uf.Unite(i,j) not uf.isSameGroup(i,j) uf.isSameGroup(i,j) uf.isSameGroup uf isSameGroup i j k=uf.Count(i)*uf.Count(j) k uf.Count(i)*uf.Count(j) uf.Count(i) uf.Count uf Count i uf.Count(j) uf.Count uf Count j n_m-=k n_m k uf.Unite(i,j) uf.Unite uf Unite i j for i in ans[::-1]:
  print(i) i ans[::-1] ans ::-1 -1 print(i) print i k=uf.Count(i)*uf.Count(j) uf.Count(i)*uf.Count(j) k n_m-=k k n_m class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)] class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)] UnionFind n_m=n*(n-1)//2 n*(n-1)//2 n_m m=map(int,input().split()) map(int,input().split()) m b=map(int,input().split()) map(int,input().split()) b n,m=map(int,input().split()) map(int,input().split()) n uf=UnionFind(n) UnionFind(n) uf a,b=map(int,input().split()) map(int,input().split()) a e=[] [] e ans=[] [] ans
from itertools import combinations
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n,m=map(int,input().split())
uf=UnionFind(n)
e=[]
ans=[]
for _ in range(m):
  a,b=map(int,input().split())
  e.append((a,b))
n_m=n*(n-1)//2
for i,j in e[::-1]:
  ans.append(n_m)
  if not uf.isSameGroup(i,j):
    k=uf.Count(i)*uf.Count(j)
    n_m-=k
    uf.Unite(i,j)
for i in ans[::-1]:
  print(i)