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):
        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 = 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
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    def get_group(self):
        a=0
        for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
        return a
N,M=map(int,input().split())
lity=[]
lity.append(int(N*(N-1)/2))
ans=0
uf=UnionFind(N)
AB=[list(map(int,input().split())) for i in range(M)]
for i in range(M-1,-1,-1):
  a,b=AB[i]
  x=uf.find(a-1)
  y=uf.find(b-1)
  sizex=0
  sizey=0
  if x!=y:
    sizex=uf.get_size(a-1)
    sizey=uf.get_size(b-1)
  uf.union(a-1,b-1)
  ans=lity[-1]-sizex*sizey
  lity.append(ans)
for j in range(M-1,-1,-1):
  print(lity[j]) 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):
        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 = 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
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    def get_group(self):
        a=0
        for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
        return a 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):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
     find 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 = 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
            self.size[x] += self.size[y]
     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:
            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
            self.size[x] += self.size[y]
     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 self.size[x] += self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y self self x x y y def is_same(self, x, y):
        return self.find(x) == self.find(y)
     is_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 get_size(self, x):
        x = self.find(x)
        return self.size[x]
     get_size 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 def get_group(self):
        a=0
        for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
        return a get_group a=0 a 0 for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
         i range(len(self.par)) range len(self.par) len self.par self par if self.find(i)==i:
            a+=1
         self.find(i)==i self.find(i) self.find self find i i a+=1 a 1 return a a self self object N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M lity=[] lity [] lity.append(int(N*(N-1)/2)) lity.append lity append int(N*(N-1)/2) int N*(N-1)/2 N*(N-1) N N-1 N 1 2 ans=0 ans 0 uf=UnionFind(N) uf UnionFind(N) UnionFind N 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(map(int,input().split())) for i in range(M)] AB [list(map(int,input().split())) for i in range(M)] for i in range(M-1,-1,-1):
  a,b=AB[i]
  x=uf.find(a-1)
  y=uf.find(b-1)
  sizex=0
  sizey=0
  if x!=y:
    sizex=uf.get_size(a-1)
    sizey=uf.get_size(b-1)
  uf.union(a-1,b-1)
  ans=lity[-1]-sizex*sizey
  lity.append(ans) i range(M-1,-1,-1) range M-1 M 1 -1 -1 a,b=AB[i] a AB[i] AB i b x=uf.find(a-1) x uf.find(a-1) uf.find uf find a-1 a 1 y=uf.find(b-1) y uf.find(b-1) uf.find uf find b-1 b 1 sizex=0 sizex 0 sizey=0 sizey 0 if x!=y:
    sizex=uf.get_size(a-1)
    sizey=uf.get_size(b-1)
   x!=y x y sizex=uf.get_size(a-1) sizex uf.get_size(a-1) uf.get_size uf get_size a-1 a 1 sizey=uf.get_size(b-1) sizey uf.get_size(b-1) uf.get_size uf get_size b-1 b 1 uf.union(a-1,b-1) uf.union uf union a-1 a 1 b-1 b 1 ans=lity[-1]-sizex*sizey ans lity[-1]-sizex*sizey lity[-1] lity -1 sizex*sizey sizex sizey lity.append(ans) lity.append lity append ans for j in range(M-1,-1,-1):
  print(lity[j]) j range(M-1,-1,-1) range M-1 M 1 -1 -1 print(lity[j]) print lity[j] lity j AB=[list(map(int,input().split())) for i in range(M)] [list(map(int,input().split())) for i in range(M)] AB x=uf.find(a-1) uf.find(a-1) x sizex=0 0 sizex sizey=0 0 sizey ans=lity[-1]-sizex*sizey lity[-1]-sizex*sizey ans uf=UnionFind(N) UnionFind(N) uf a,b=AB[i] AB[i] a N,M=map(int,input().split()) map(int,input().split()) N 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):
        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 = 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
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    def get_group(self):
        a=0
        for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
        return a 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):
        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 = 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
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    def get_group(self):
        a=0
        for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
        return a UnionFind ans=0 0 ans b=AB[i] AB[i] b sizex=uf.get_size(a-1) uf.get_size(a-1) sizex M=map(int,input().split()) map(int,input().split()) M y=uf.find(b-1) uf.find(b-1) y sizey=uf.get_size(b-1) uf.get_size(b-1) sizey lity=[] [] lity
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):
        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 = 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
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    def get_group(self):
        a=0
        for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
        return a
N,M=map(int,input().split())
lity=[]
lity.append(int(N*(N-1)/2))
ans=0
uf=UnionFind(N)
AB=[list(map(int,input().split())) for i in range(M)]
for i in range(M-1,-1,-1):
  a,b=AB[i]
  x=uf.find(a-1)
  y=uf.find(b-1)
  sizex=0
  sizey=0
  if x!=y:
    sizex=uf.get_size(a-1)
    sizey=uf.get_size(b-1)
  uf.union(a-1,b-1)
  ans=lity[-1]-sizex*sizey
  lity.append(ans)
for j in range(M-1,-1,-1):
  print(lity[j])