class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2
            self.size[x] += self.size[y]
            return ((self.size[x] * (self.size[x]-1)) // 2 - prev)
        return 0            
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
      
n,m = map(int, input().split())
ab = list(reversed([list(map(int, input().split())) for i in range(m)]))
now = n * (n-1) // 2 
ans = [now]
U = UnionFind(n)                    
for a,b in ab[:-1]:
  minus = U.union(a-1,b-1)
  now -= minus
  ans.append(now)
ans.reverse()
for i in ans:
  print(i) class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2
            self.size[x] += self.size[y]
            return ((self.size[x] * (self.size[x]-1)) // 2 - prev)
        return 0            
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
       UnionFind def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

     __init__ i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.par = [i for i in range(n)] self.par self par [i for i in range(n)] 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 self.rank = [0 for _ in range(n)] self.rank self rank [0 for _ in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 self.size = [1 for _ in range(n)] self.size self size [1 for _ in range(n)] self self n=1 n 1 def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     find """
        x が属するグループを探索
        """ if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     self.par[x] == x self.par[x] self.par self par x x return x x self.par[x] = self.find(self.par[x]) self.par[x] self.par self par x self.find(self.par[x]) self.find self find self.par[x] self.par self par x return self.par[x] self.par[x] self.par self par x self self x x def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2
            self.size[x] += self.size[y]
            return ((self.size[x] * (self.size[x]-1)) // 2 - prev)
        return 0            
     union """
        x と y のグループを結合
        """ 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:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2
            self.size[x] += self.size[y]
            return ((self.size[x] * (self.size[x]-1)) // 2 - prev)
         x != y x y if self.rank[x] < self.rank[y]:
                x, y = y, x
             self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y x, y = y, x x y y x if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
             self.rank[x] == self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.rank[x] += 1 self.rank[x] self.rank self rank x 1 self.par[y] = x self.par[y] self.par self par y x prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2 prev ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2 (self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1)) self.size[x] * (self.size[x]-1) self.size[x] self.size self size x self.size[x]-1 self.size[x] self.size self size x 1 self.size[y] * (self.size[y]-1) self.size[y] self.size self size y self.size[y]-1 self.size[y] self.size self size y 1 2 self.size[x] += self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y return ((self.size[x] * (self.size[x]-1)) // 2 - prev) (self.size[x] * (self.size[x]-1)) // 2 - prev (self.size[x] * (self.size[x]-1)) // 2 self.size[x] * (self.size[x]-1) self.size[x] self.size self size x self.size[x]-1 self.size[x] self.size self size x 1 2 prev return 0 0 self self x x y y def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

     is_same """
        x と y が同じグループか否か
        """ 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 get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
       get_size """
        x が属するグループの要素数
        """ x = self.find(x) x self.find(x) self.find self find x return self.size[x] self.size[x] self.size self size x self self x x object n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ab = list(reversed([list(map(int, input().split())) for i in range(m)])) ab list(reversed([list(map(int, input().split())) for i in range(m)])) list reversed([list(map(int, input().split())) for i in range(m)]) reversed [list(map(int, input().split())) for i in range(m)] now = n * (n-1) // 2 now n * (n-1) // 2 n * (n-1) n n-1 n 1 2 ans = [now] ans [now] now U = UnionFind(n) U UnionFind(n) UnionFind n for a,b in ab[:-1]:
  minus = U.union(a-1,b-1)
  now -= minus
  ans.append(now) a b ab[:-1] ab :-1 -1 minus = U.union(a-1,b-1) minus U.union(a-1,b-1) U.union U union a-1 a 1 b-1 b 1 now -= minus now minus ans.append(now) ans.append ans append now ans.reverse() ans.reverse ans reverse for i in ans:
  print(i) i ans print(i) print i now -= minus minus now class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2
            self.size[x] += self.size[y]
            return ((self.size[x] * (self.size[x]-1)) // 2 - prev)
        return 0            
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
       class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2
            self.size[x] += self.size[y]
            return ((self.size[x] * (self.size[x]-1)) // 2 - prev)
        return 0            
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
       UnionFind U = UnionFind(n) UnionFind(n) U ans = [now] [now] ans m = map(int, input().split()) map(int, input().split()) m ab = list(reversed([list(map(int, input().split())) for i in range(m)])) list(reversed([list(map(int, input().split())) for i in range(m)])) ab minus = U.union(a-1,b-1) U.union(a-1,b-1) minus n,m = map(int, input().split()) map(int, input().split()) n now = n * (n-1) // 2 n * (n-1) // 2 now
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            prev = ((self.size[x] * (self.size[x]-1)) + (self.size[y] * (self.size[y]-1))) // 2
            self.size[x] += self.size[y]
            return ((self.size[x] * (self.size[x]-1)) // 2 - prev)
        return 0            
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
      
n,m = map(int, input().split())
ab = list(reversed([list(map(int, input().split())) for i in range(m)]))
now = n * (n-1) // 2 
ans = [now]
U = UnionFind(n)                    
for a,b in ab[:-1]:
  minus = U.union(a-1,b-1)
  now -= minus
  ans.append(now)
ans.reverse()
for i in ans:
  print(i)