class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)
n,m=map(int,input().split())
uf = UnionFind(n)
edges=[]
for i in range(m):
  edges.append(list(map(int,input().split())))
current=(n*(n-1))//2
ans=[current]
for i in range(m-1):
  u=edges[m-1-i][0]-1
  v=edges[m-1-i][1]-1
  if uf.same(u,v)==1:
    ans.append(current)
  else:
    size1=uf.size(u)
    size2=uf.size(v)
    current-=size1*size2
    ans.append(current)
    uf.union(u,v)
ans.reverse()
for i in ans:
  print(i) class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

     __init__ self.n = n self.n self n n 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
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

     find if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[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 size(self, x):
        return -self.parents[self.find(x)]

     size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x 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 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 edges=[] edges [] for i in range(m):
  edges.append(list(map(int,input().split()))) i range(m) range m edges.append(list(map(int,input().split()))) edges.append edges append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split current=(n*(n-1))//2 current (n*(n-1))//2 n*(n-1) n n-1 n 1 2 ans=[current] ans [current] current for i in range(m-1):
  u=edges[m-1-i][0]-1
  v=edges[m-1-i][1]-1
  if uf.same(u,v)==1:
    ans.append(current)
  else:
    size1=uf.size(u)
    size2=uf.size(v)
    current-=size1*size2
    ans.append(current)
    uf.union(u,v) i range(m-1) range m-1 m 1 u=edges[m-1-i][0]-1 u edges[m-1-i][0]-1 edges[m-1-i][0] [m-1-i] edges m-1-i m-1 m 1 i 0 1 v=edges[m-1-i][1]-1 v edges[m-1-i][1]-1 edges[m-1-i][1] [m-1-i] edges m-1-i m-1 m 1 i 1 1 if uf.same(u,v)==1:
    ans.append(current)
  else:
    size1=uf.size(u)
    size2=uf.size(v)
    current-=size1*size2
    ans.append(current)
    uf.union(u,v) uf.same(u,v)==1 uf.same(u,v) uf.same uf same u v 1 ans.append(current) ans.append ans append current size1=uf.size(u) size1 uf.size(u) uf.size uf size u size2=uf.size(v) size2 uf.size(v) uf.size uf size v current-=size1*size2 current size1*size2 size1 size2 ans.append(current) ans.append ans append current uf.union(u,v) uf.union uf union u v ans.reverse() ans.reverse ans reverse for i in ans:
  print(i) i ans print(i) print i v=edges[m-1-i][1]-1 edges[m-1-i][1]-1 v class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind u=edges[m-1-i][0]-1 edges[m-1-i][0]-1 u ans=[current] [current] ans size1=uf.size(u) uf.size(u) size1 m=map(int,input().split()) map(int,input().split()) m size2=uf.size(v) uf.size(v) size2 uf = UnionFind(n) UnionFind(n) uf n,m=map(int,input().split()) map(int,input().split()) n current-=size1*size2 size1*size2 current edges=[] [] edges current=(n*(n-1))//2 (n*(n-1))//2 current
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)
n,m=map(int,input().split())
uf = UnionFind(n)
edges=[]
for i in range(m):
  edges.append(list(map(int,input().split())))
current=(n*(n-1))//2
ans=[current]
for i in range(m-1):
  u=edges[m-1-i][0]-1
  v=edges[m-1-i][1]-1
  if uf.same(u,v)==1:
    ans.append(current)
  else:
    size1=uf.size(u)
    size2=uf.size(v)
    current-=size1*size2
    ans.append(current)
    uf.union(u,v)
ans.reverse()
for i in ans:
  print(i)